From 2678060eae574f3ff0858cd7907feaeb3c1f43df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Tue, 13 Sep 2016 09:37:46 +0200 Subject: implement ON_SLIT actions On the run, make it raise on left-clicks (like the toolbar) The enum already existed ;-) REQUEST: 113 --- doc/asciidoc/fluxbox-keys.txt | 3 +++ src/Keys.cc | 8 ++++++-- src/Slit.cc | 33 ++++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index b7ae264..26a148b 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt @@ -62,6 +62,9 @@ There are also some special modifiers that refer to mouse button events::: *OnToolbar*;; The mouse cursor is over the toolbar (which is normally at the bottom of the screen). +*OnSlit*;; + The mouse cursor is over the mystic slit (the thing that collects dock type + windows). *OnWindow*;; The mouse cursor is over a window. *OnTitlebar*;; diff --git a/src/Keys.cc b/src/Keys.cc index 846edea..774cd05 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -396,6 +396,8 @@ bool Keys::addBinding(const string &linebuffer) { context |= ON_DESKTOP; else if (arg == "ontoolbar") context |= ON_TOOLBAR; + else if (arg == "onslit") + context |= ON_SLIT; else if (arg == "onwindow") context |= ON_WINDOW; else if (arg == "ontitlebar") @@ -431,12 +433,12 @@ bool Keys::addBinding(const string &linebuffer) { type = FocusIn; } else if (arg == "mouseover") { type = EnterNotify; - if (!(context & (ON_WINDOW|ON_TOOLBAR))) + if (!(context & (ON_WINDOW|ON_TOOLBAR|ON_SLIT))) context |= ON_WINDOW; key = 0; } else if (arg == "mouseout") { type = LeaveNotify; - if (!(context & (ON_WINDOW|ON_TOOLBAR))) + if (!(context & (ON_WINDOW|ON_TOOLBAR|ON_SLIT))) context |= ON_WINDOW; key = 0; @@ -451,6 +453,8 @@ bool Keys::addBinding(const string &linebuffer) { context = ON_TITLEBAR; else if (strstr(arg.c_str(), "bar")) context = ON_TOOLBAR; + else if (strstr(arg.c_str(), "slit")) + context = ON_SLIT; else if (strstr(arg.c_str(), "ow")) context = ON_WINDOW; } else if (extractKeyFromString(arg, "click", key)) { diff --git a/src/Slit.cc b/src/Slit.cc index 37c3b1f..a7bd50f 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -36,6 +36,7 @@ #include "FbTk/MemFun.hh" #include "FbCommands.hh" +#include "Keys.hh" #include "Layer.hh" #include "LayerMenu.hh" #include "FbTk/Layer.hh" @@ -275,6 +276,8 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename) FbTk::EventManager::instance()->add(*this, frame.window); + FbTk::EventManager::instance()->addParent(*this, window()); + Fluxbox::instance()->keys()->registerWindow(window().window(), *this, Keys::ON_SLIT); if (FbTk::Transparent::haveComposite()) { frame.window.setOpaque(*m_rc_alpha); @@ -943,16 +946,27 @@ void Slit::handleEvent(XEvent &event) { } void Slit::buttonPressEvent(XButtonEvent &be) { - if (be.window != frame.window.window()) + Display *dpy = Fluxbox::instance()->display(); + const bool myMenuWasVisible = m_slitmenu.isVisible(); + + FbTk::Menu::hideShownMenu(); + + if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button, + Keys::ON_SLIT, 0, be.time)) { + XAllowEvents(dpy, SyncPointer, CurrentTime); return; + } + + if (be.button == 1) + frame.window.raise(); - if (be.button == Button3) { - if (! m_slitmenu.isVisible()) { - screen().placementStrategy() - .placeAndShowMenu(m_slitmenu, be.x_root, be.y_root, false); - } else - m_slitmenu.hide(); + if (be.button != Button3) { + XAllowEvents(dpy, ReplayPointer, CurrentTime); + return; } + + if (!myMenuWasVisible) + screen().placementStrategy().placeAndShowMenu(m_slitmenu, be.x_root, be.y_root, false); } @@ -979,6 +993,8 @@ void Slit::updateCrossingState() { } void Slit::enterNotifyEvent(XCrossingEvent &ce) { + Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, Keys::ON_SLIT); + if (!m_rc_auto_hide && isHidden()) { toggleHidden(); } @@ -995,6 +1011,9 @@ void Slit::leaveNotifyEvent(XCrossingEvent &event) { if (!m_timer.isTiming() && (m_rc_auto_hide && !isHidden()) || (m_rc_auto_raise && m_layeritem->getLayerNum() != m_rc_layernum->getNum())) m_timer.start(); + + if (!isHidden()) + Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, Keys::ON_SLIT); } void Slit::configureRequestEvent(XConfigureRequestEvent &event) { -- cgit v0.11.2