allow the user to specify the modmask used to mouse events on windows

This commit is contained in:
Dana Jansens 2002-08-10 18:21:10 +00:00
parent 6e07a64d33
commit f633c5f057
4 changed files with 48 additions and 14 deletions

View file

@ -62,11 +62,6 @@ extern "C" {
using std::string;
using std::abs;
// change this to change what modifier keys openbox uses for mouse bindings
// for example: Mod1Mask | ControlMask
// or: ControlMask| ShiftMask
const unsigned int ModMask = Mod1Mask;
/*
* Initializes the class with default values/the window's set initial values.
*/
@ -893,6 +888,8 @@ void BlackboxWindow::reconfigure(void) {
void BlackboxWindow::grabButtons(void) {
mod_mask = blackbox->getMouseModMask();
if (! screen->isSloppyFocus() || screen->doClickRaise())
// grab button 1 for changing focus/raising
blackbox->grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
@ -900,17 +897,17 @@ void BlackboxWindow::grabButtons(void) {
screen->allowScrollLock());
if (functions & Func_Move)
blackbox->grabButton(Button1, ModMask, frame.window, True,
blackbox->grabButton(Button1, mod_mask, frame.window, True,
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
GrabModeAsync, frame.window, None,
screen->allowScrollLock());
if (functions & Func_Resize)
blackbox->grabButton(Button3, ModMask, frame.window, True,
blackbox->grabButton(Button3, mod_mask, frame.window, True,
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
GrabModeAsync, frame.window, None,
screen->allowScrollLock());
// alt+middle lowers the window
blackbox->grabButton(Button2, ModMask, frame.window, True,
blackbox->grabButton(Button2, mod_mask, frame.window, True,
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
frame.window, None,
screen->allowScrollLock());
@ -919,9 +916,9 @@ void BlackboxWindow::grabButtons(void) {
void BlackboxWindow::ungrabButtons(void) {
blackbox->ungrabButton(Button1, 0, frame.plate);
blackbox->ungrabButton(Button1, ModMask, frame.window);
blackbox->ungrabButton(Button2, ModMask, frame.window);
blackbox->ungrabButton(Button3, ModMask, frame.window);
blackbox->ungrabButton(Button1, mod_mask, frame.window);
blackbox->ungrabButton(Button2, mod_mask, frame.window);
blackbox->ungrabButton(Button3, mod_mask, frame.window);
}
@ -2864,7 +2861,7 @@ void BlackboxWindow::buttonPressEvent(const XButtonEvent *be) {
if (frame.maximize_button == be->window && be->button <= 3) {
redrawMaximizeButton(True);
} else if (be->button == 1 || (be->button == 3 && be->state == ModMask)) {
} else if (be->button == 1 || (be->button == 3 && be->state == mod_mask)) {
if (! flags.focused)
setInputFocus();
@ -2990,7 +2987,7 @@ void BlackboxWindow::buttonReleaseEvent(const XButtonEvent *re) {
} else if (flags.resizing) {
endResize();
} else if (re->window == frame.window) {
if (re->button == 2 && re->state == ModMask)
if (re->button == 2 && re->state == mod_mask)
XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
}
}
@ -3622,7 +3619,7 @@ void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) {
} else if ((functions & Func_Resize) &&
(me->state & Button1Mask && (me->window == frame.right_grip ||
me->window == frame.left_grip)) ||
(me->state & Button3Mask && me->state & ModMask &&
(me->state & Button3Mask && me->state & mod_mask &&
me->window == frame.window)) {
unsigned int zones = screen->getResizeZones();
Corner corner;

View file

@ -134,6 +134,7 @@ private:
unsigned int window_number;
unsigned long current_state;
unsigned int mod_mask; // the mod mask used to grab buttons
enum FocusMode { F_NoInput = 0, F_Passive,
F_LocallyActive, F_GloballyActive };

View file

@ -1169,6 +1169,17 @@ void Blackbox::save_rc(void) {
config.setValue("session.cacheMax", resource.cache_max);
config.setValue("session.styleFile", resource.style_file);
config.setValue("session.titlebarLayout", resource.titlebar_layout);
string s;
if (resource.mod_mask & Mod1Mask) s += "Mod1-";
if (resource.mod_mask & Mod2Mask) s += "Mod2-";
if (resource.mod_mask & Mod3Mask) s += "Mod3-";
if (resource.mod_mask & Mod4Mask) s += "Mod4-";
if (resource.mod_mask & Mod5Mask) s += "Mod5-";
if (resource.mod_mask & ShiftMask) s += "Shift-";
if (resource.mod_mask & ControlMask) s += "Control-";
s.resize(s.size() - 1); // drop the last '-'
config.setValue("session.modifierMask", s);
#ifdef XINERAMA
saveXineramaPlacement(resource.xinerama_placement);
@ -1236,6 +1247,26 @@ void Blackbox::load_rc(void) {
resource.xinerama_snap))
resource.xinerama_snap = false;
#endif // XINERAMA
resource.mod_mask = 0;
if (config.getValue("session.modifierMask", s)) {
if (s.find("Mod1") != string::npos)
resource.mod_mask |= Mod1Mask;
if (s.find("Mod2") != string::npos)
resource.mod_mask |= Mod2Mask;
if (s.find("Mod3") != string::npos)
resource.mod_mask |= Mod3Mask;
if (s.find("Mod4") != string::npos)
resource.mod_mask |= Mod4Mask;
if (s.find("Mod5") != string::npos)
resource.mod_mask |= Mod5Mask;
if (s.find("Shift") != string::npos)
resource.mod_mask |= ShiftMask;
if (s.find("Control") != string::npos)
resource.mod_mask |= ControlMask;
}
if (! resource.mod_mask)
resource.mod_mask = Mod1Mask;
}

View file

@ -115,6 +115,8 @@ private:
timeval auto_raise_delay;
unsigned long cache_life, cache_max;
std::string titlebar_layout;
unsigned int mod_mask; // modifier mask used for window-mouse interaction
#ifdef XINERAMA
bool xinerama_placement, xinerama_maximize, xinerama_snap;
@ -254,6 +256,9 @@ public:
{ return cursor.ul_angle; }
inline Cursor getUpperRightAngleCursor(void) const
{ return cursor.ur_angle; }
inline unsigned int getMouseModMask(void) const
{ return resource.mod_mask; }
void setFocusedWindow(BlackboxWindow *win);
void setChangingWindow(BlackboxWindow *win);