implement ON_SLIT actions

On the run, make it raise on left-clicks (like the toolbar)

The enum already existed ;-)

REQUEST: 113
This commit is contained in:
Thomas Lübking 2016-09-13 09:37:46 +02:00 committed by Mathias Gumz
parent 4545f4dac8
commit 2678060eae
3 changed files with 36 additions and 10 deletions

View file

@ -62,6 +62,9 @@ There are also some special modifiers that refer to mouse button events:::
*OnToolbar*;; *OnToolbar*;;
The mouse cursor is over the toolbar (which is normally at the bottom The mouse cursor is over the toolbar (which is normally at the bottom
of the screen). of the screen).
*OnSlit*;;
The mouse cursor is over the mystic slit (the thing that collects dock type
windows).
*OnWindow*;; *OnWindow*;;
The mouse cursor is over a window. The mouse cursor is over a window.
*OnTitlebar*;; *OnTitlebar*;;

View file

@ -396,6 +396,8 @@ bool Keys::addBinding(const string &linebuffer) {
context |= ON_DESKTOP; context |= ON_DESKTOP;
else if (arg == "ontoolbar") else if (arg == "ontoolbar")
context |= ON_TOOLBAR; context |= ON_TOOLBAR;
else if (arg == "onslit")
context |= ON_SLIT;
else if (arg == "onwindow") else if (arg == "onwindow")
context |= ON_WINDOW; context |= ON_WINDOW;
else if (arg == "ontitlebar") else if (arg == "ontitlebar")
@ -431,12 +433,12 @@ bool Keys::addBinding(const string &linebuffer) {
type = FocusIn; type = FocusIn;
} else if (arg == "mouseover") { } else if (arg == "mouseover") {
type = EnterNotify; type = EnterNotify;
if (!(context & (ON_WINDOW|ON_TOOLBAR))) if (!(context & (ON_WINDOW|ON_TOOLBAR|ON_SLIT)))
context |= ON_WINDOW; context |= ON_WINDOW;
key = 0; key = 0;
} else if (arg == "mouseout") { } else if (arg == "mouseout") {
type = LeaveNotify; type = LeaveNotify;
if (!(context & (ON_WINDOW|ON_TOOLBAR))) if (!(context & (ON_WINDOW|ON_TOOLBAR|ON_SLIT)))
context |= ON_WINDOW; context |= ON_WINDOW;
key = 0; key = 0;
@ -451,6 +453,8 @@ bool Keys::addBinding(const string &linebuffer) {
context = ON_TITLEBAR; context = ON_TITLEBAR;
else if (strstr(arg.c_str(), "bar")) else if (strstr(arg.c_str(), "bar"))
context = ON_TOOLBAR; context = ON_TOOLBAR;
else if (strstr(arg.c_str(), "slit"))
context = ON_SLIT;
else if (strstr(arg.c_str(), "ow")) else if (strstr(arg.c_str(), "ow"))
context = ON_WINDOW; context = ON_WINDOW;
} else if (extractKeyFromString(arg, "click", key)) { } else if (extractKeyFromString(arg, "click", key)) {

View file

@ -36,6 +36,7 @@
#include "FbTk/MemFun.hh" #include "FbTk/MemFun.hh"
#include "FbCommands.hh" #include "FbCommands.hh"
#include "Keys.hh"
#include "Layer.hh" #include "Layer.hh"
#include "LayerMenu.hh" #include "LayerMenu.hh"
#include "FbTk/Layer.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()->add(*this, frame.window);
FbTk::EventManager::instance()->addParent(*this, window());
Fluxbox::instance()->keys()->registerWindow(window().window(), *this, Keys::ON_SLIT);
if (FbTk::Transparent::haveComposite()) { if (FbTk::Transparent::haveComposite()) {
frame.window.setOpaque(*m_rc_alpha); frame.window.setOpaque(*m_rc_alpha);
@ -943,16 +946,27 @@ void Slit::handleEvent(XEvent &event) {
} }
void Slit::buttonPressEvent(XButtonEvent &be) { void Slit::buttonPressEvent(XButtonEvent &be) {
if (be.window != frame.window.window()) Display *dpy = Fluxbox::instance()->display();
return; const bool myMenuWasVisible = m_slitmenu.isVisible();
if (be.button == Button3) { FbTk::Menu::hideShownMenu();
if (! m_slitmenu.isVisible()) {
screen().placementStrategy() if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button,
.placeAndShowMenu(m_slitmenu, be.x_root, be.y_root, false); Keys::ON_SLIT, 0, be.time)) {
} else XAllowEvents(dpy, SyncPointer, CurrentTime);
m_slitmenu.hide(); return;
} }
if (be.button == 1)
frame.window.raise();
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) { void Slit::enterNotifyEvent(XCrossingEvent &ce) {
Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, Keys::ON_SLIT);
if (!m_rc_auto_hide && isHidden()) { if (!m_rc_auto_hide && isHidden()) {
toggleHidden(); toggleHidden();
} }
@ -995,6 +1011,9 @@ void Slit::leaveNotifyEvent(XCrossingEvent &event) {
if (!m_timer.isTiming() && (m_rc_auto_hide && !isHidden()) || if (!m_timer.isTiming() && (m_rc_auto_hide && !isHidden()) ||
(m_rc_auto_raise && m_layeritem->getLayerNum() != m_rc_layernum->getNum())) (m_rc_auto_raise && m_layeritem->getLayerNum() != m_rc_layernum->getNum()))
m_timer.start(); m_timer.start();
if (!isHidden())
Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, Keys::ON_SLIT);
} }
void Slit::configureRequestEvent(XConfigureRequestEvent &event) { void Slit::configureRequestEvent(XConfigureRequestEvent &event) {