From 72130f350ef08c6200d18e544b861940cbcb7526 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 15 Oct 2007 18:05:28 +0000 Subject: add OnWindow modifier to keys file --- ChangeLog | 3 +++ src/CurrentWindowCmd.cc | 9 +++++++-- src/Keys.cc | 2 ++ src/Screen.cc | 3 +++ src/Window.cc | 13 +++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a02886..0c2f0a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0.1: +*07/10/15: + * Added OnWindow modifier to keys file (Mark) + Keys.cc Window.cc Screen.cc CurrentWindowCmd.cc *07/10/14: * Added support for transient windows in window patterns, e.g. (transient=yes|no), defaulting to "no" for the apps file (Mark) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 58ec78c..01b8de7 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -26,6 +26,7 @@ #include "fluxbox.hh" #include "Window.hh" +#include "WindowCmd.hh" #include "Screen.hh" #include "WinClient.hh" @@ -33,7 +34,7 @@ void WindowHelperCmd::execute() { m_win = 0; - if (FocusControl::focusedFbWindow()) // guarantee that fbwindow() exists too + if (WindowCmd::window() || FocusControl::focusedFbWindow()) real_execute(); } @@ -44,7 +45,11 @@ void WindowHelperCmd::execute(FluxboxWindow &win) { FluxboxWindow &WindowHelperCmd::fbwindow() { // will exist from execute above - return (m_win ? *m_win : *FocusControl::focusedFbWindow()); + if (m_win) + return *m_win; + FluxboxWindow *tmp = WindowCmd::window(); + if (tmp) return *tmp; + return *FocusControl::focusedFbWindow(); } void CurrentWindowCmd::real_execute() { diff --git a/src/Keys.cc b/src/Keys.cc index 6d13cd4..34d5cc0 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -301,6 +301,8 @@ bool Keys::addBinding(const string &linebuffer) { context |= ON_DESKTOP; else if (strcasecmp("ontoolbar", val[argc].c_str()) == 0) context |= ON_TOOLBAR; + else if (strcasecmp("onwindow", val[argc].c_str()) == 0) + context |= ON_WINDOW; else if (strcasecmp("NONE",val[argc].c_str())) { // check if it's a mouse button if (!strcasecmp(val[argc].substr(0,5).c_str(), "mouse") && diff --git a/src/Screen.cc b/src/Screen.cc index d843a53..5549ca5 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -30,6 +30,7 @@ #include "fluxbox.hh" #include "Keys.hh" #include "Window.hh" +#include "WindowCmd.hh" #include "Workspace.hh" #include "Layer.hh" @@ -827,6 +828,7 @@ void BScreen::propertyNotify(Atom atom) { void BScreen::keyPressEvent(XKeyEvent &ke) { if (!m_typing_ahead) { + WindowCmd::setWindow(FocusControl::focusedFbWindow()); Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, Keys::GLOBAL|Keys::ON_DESKTOP); return; @@ -882,6 +884,7 @@ void BScreen::buttonPressEvent(XButtonEvent &be) { imageControl().installRootColormap(); Keys *keys = Fluxbox::instance()->keys(); + WindowCmd::setWindow(FocusControl::focusedFbWindow()); keys->doAction(be.type, be.state, be.button, Keys::GLOBAL|Keys::ON_DESKTOP); } diff --git a/src/Window.cc b/src/Window.cc index 27bc7ec..5e9aec5 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -28,6 +28,7 @@ #include "WinClient.hh" #include "fluxbox.hh" +#include "Keys.hh" #include "Screen.hh" #include "FbWinFrameTheme.hh" #include "FbAtoms.hh" @@ -285,6 +286,9 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, else screen().focusControl().addFocusWinBack(*this); + Fluxbox::instance()->keys()->registerWindow(frame().window().window(), + Keys::ON_WINDOW); + } @@ -292,6 +296,8 @@ FluxboxWindow::~FluxboxWindow() { if (WindowCmd::window() == this) WindowCmd::setWindow(0); + Fluxbox::instance()->keys()->unregisterWindow(frame().window().window()); + #ifdef DEBUG const char* title = m_client ? m_client->title().c_str() : "" ; cerr<<__FILE__<<"("<<__LINE__<<"): starting ~FluxboxWindow("<::setWindow(this); + if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button, + Keys::ON_WINDOW)) { + return; + } + // check frame events first frame().buttonPressEvent(be); -- cgit v0.11.2