kill button release events
This commit is contained in:
parent
54da8e404b
commit
e05d5f7934
11 changed files with 101 additions and 56 deletions
|
@ -20,24 +20,37 @@ def def_motion_release(data):
|
||||||
posqueue.remove(i)
|
posqueue.remove(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def def_do_move(xroot, yroot, client):
|
||||||
|
global posqueue
|
||||||
|
dx = xroot - posqueue[0][1]
|
||||||
|
dy = yroot - posqueue[0][2]
|
||||||
|
area = posqueue[0][3] # A Rect
|
||||||
|
OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
|
||||||
|
|
||||||
|
def def_do_resize(xroot, yroot, client, anchor_corner):
|
||||||
|
global posqueue
|
||||||
|
dx = xroot - posqueue[0][1]
|
||||||
|
dy = yroot - posqueue[0][2]
|
||||||
|
OBClient_resize(client, anchor_corner,
|
||||||
|
Rect_width(area) - dx, Rect_height(area) + dy)
|
||||||
|
|
||||||
def def_motion(data):
|
def def_motion(data):
|
||||||
client = Openbox_findClient(openbox, data.window())
|
client = Openbox_findClient(openbox, data.window())
|
||||||
if not client: return
|
if not client: return
|
||||||
|
|
||||||
global posqueue
|
global posqueue
|
||||||
dx = data.xroot() - posqueue[0][1]
|
if not posqueue[0][0] == 1: return
|
||||||
dy = data.yroot() - posqueue[0][2]
|
|
||||||
|
|
||||||
area = posqueue[0][3] # A Rect
|
|
||||||
type = data.target()
|
type = data.target()
|
||||||
if (type == Type_Titlebar) or (type == Type_Label):
|
if (type == Type_Titlebar) or (type == Type_Label) or \
|
||||||
OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
|
(type == Type_Plate) or (type == Type_Handle):
|
||||||
|
def_do_move(data.xroot(), data.yroot(), client)
|
||||||
elif type == Type_LeftGrip:
|
elif type == Type_LeftGrip:
|
||||||
OBClient_resize(client, OBClient_TopRight,
|
def_do_resize(data.xroot(), data.yroot(), client,
|
||||||
Rect_width(area) - dx, Rect_height(area) + dy)
|
OBClient_TopRight)
|
||||||
elif type == Type_RightGrip:
|
elif type == Type_RightGrip:
|
||||||
OBClient_resize(client, OBClient_TopLeft,
|
def_do_resize(data.xroot(), data.yroot(), client,
|
||||||
Rect_width(area) + dx, Rect_height(area) + dy)
|
OBClient_TopLeft)
|
||||||
|
|
||||||
def def_enter(data):
|
def def_enter(data):
|
||||||
client = Openbox_findClient(openbox, data.window())
|
client = Openbox_findClient(openbox, data.window())
|
||||||
|
|
|
@ -56,11 +56,6 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
|
||||||
OBWidget *w = dynamic_cast<OBWidget*>
|
OBWidget *w = dynamic_cast<OBWidget*>
|
||||||
(Openbox::instance->findHandler(e.window));
|
(Openbox::instance->findHandler(e.window));
|
||||||
|
|
||||||
// run the RELEASE python hook
|
|
||||||
doCallback(Action_ButtonRelease, e.window,
|
|
||||||
(OBWidget::WidgetType)(w ? w->type():-1),
|
|
||||||
e.state, e.button, e.x_root, e.y_root, e.time);
|
|
||||||
|
|
||||||
// not for the button we're watching?
|
// not for the button we're watching?
|
||||||
if (_button != e.button) return;
|
if (_button != e.button) return;
|
||||||
|
|
||||||
|
@ -163,7 +158,7 @@ void OBActions::motionHandler(const XMotionEvent &e)
|
||||||
// run the simple MOTION python hook for now...
|
// run the simple MOTION python hook for now...
|
||||||
doCallback(Action_MouseMotion, e.window,
|
doCallback(Action_MouseMotion, e.window,
|
||||||
(OBWidget::WidgetType)(w ? w->type():-1),
|
(OBWidget::WidgetType)(w ? w->type():-1),
|
||||||
e.state, (unsigned)-1, e.x_root, e.y_root, e.time);
|
e.state, (unsigned)-1, x_root, y_root, e.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBActions::mapRequestHandler(const XMapRequestEvent &e)
|
void OBActions::mapRequestHandler(const XMapRequestEvent &e)
|
||||||
|
|
|
@ -30,7 +30,6 @@ public:
|
||||||
// update the same enum in openbox.i when making changes to this
|
// update the same enum in openbox.i when making changes to this
|
||||||
enum ActionType {
|
enum ActionType {
|
||||||
Action_ButtonPress,
|
Action_ButtonPress,
|
||||||
Action_ButtonRelease,
|
|
||||||
Action_Click,
|
Action_Click,
|
||||||
Action_DoubleClick,
|
Action_DoubleClick,
|
||||||
Action_EnterWindow,
|
Action_EnterWindow,
|
||||||
|
|
|
@ -84,4 +84,37 @@ void OBBackgroundWidget::adjust()
|
||||||
// nothing to adjust here. its done in OBFrame::adjustSize
|
// nothing to adjust here. its done in OBFrame::adjustSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OBBackgroundWidget::grabButtons(bool grab)
|
||||||
|
{
|
||||||
|
if (grab) {
|
||||||
|
// grab simple button clicks on the client, but pass them through too
|
||||||
|
otk::OBDisplay::grabButton(Button1, 0, _window, true,
|
||||||
|
ButtonPressMask, GrabModeSync, GrabModeSync,
|
||||||
|
_window, None, false);
|
||||||
|
otk::OBDisplay::grabButton(Button2, 0, _window, true,
|
||||||
|
ButtonPressMask, GrabModeSync, GrabModeSync,
|
||||||
|
_window, None, false);
|
||||||
|
otk::OBDisplay::grabButton(Button3, 0, _window, true,
|
||||||
|
ButtonPressMask, GrabModeSync, GrabModeSync,
|
||||||
|
_window, None, false);
|
||||||
|
otk::OBDisplay::grabButton(Button4, 0, _window, true,
|
||||||
|
ButtonPressMask, GrabModeSync, GrabModeSync,
|
||||||
|
_window, None, false);
|
||||||
|
otk::OBDisplay::grabButton(Button5, 0, _window, true,
|
||||||
|
ButtonPressMask, GrabModeSync, GrabModeSync,
|
||||||
|
_window, None, false);
|
||||||
|
} else {
|
||||||
|
otk::OBDisplay::ungrabButton(Button1, 0, _window);
|
||||||
|
otk::OBDisplay::ungrabButton(Button2, 0, _window);
|
||||||
|
otk::OBDisplay::ungrabButton(Button3, 0, _window);
|
||||||
|
otk::OBDisplay::ungrabButton(Button4, 0, _window);
|
||||||
|
otk::OBDisplay::ungrabButton(Button5, 0, _window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OBBackgroundWidget::buttonPressHandler(const XButtonEvent &e)
|
||||||
|
{
|
||||||
|
XAllowEvents(otk::OBDisplay::display, ReplayPointer, e.time);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ public:
|
||||||
|
|
||||||
virtual void focus();
|
virtual void focus();
|
||||||
virtual void unfocus();
|
virtual void unfocus();
|
||||||
|
|
||||||
|
void grabButtons(bool grab);
|
||||||
|
virtual void buttonPressHandler(const XButtonEvent &e);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ static bool modvalue(const std::string &mod, unsigned int *val)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OBBindings::translate(const std::string &str, Binding &b) const
|
bool OBBindings::translate(const std::string &str, Binding &b,bool askey) const
|
||||||
{
|
{
|
||||||
// parse out the base key name
|
// parse out the base key name
|
||||||
std::string::size_type keybegin = str.find_last_of('-');
|
std::string::size_type keybegin = str.find_last_of('-');
|
||||||
|
@ -92,6 +92,7 @@ bool OBBindings::translate(const std::string &str, Binding &b) const
|
||||||
|
|
||||||
// set the binding
|
// set the binding
|
||||||
b.modifiers = modval;
|
b.modifiers = modval;
|
||||||
|
if (askey) {
|
||||||
KeySym sym = XStringToKeysym(const_cast<char *>(key.c_str()));
|
KeySym sym = XStringToKeysym(const_cast<char *>(key.c_str()));
|
||||||
if (sym == NoSymbol) {
|
if (sym == NoSymbol) {
|
||||||
printf(_("Invalid Key name in key binding: %s\n"), key.c_str());
|
printf(_("Invalid Key name in key binding: %s\n"), key.c_str());
|
||||||
|
@ -100,6 +101,9 @@ bool OBBindings::translate(const std::string &str, Binding &b) const
|
||||||
if (!(b.key = XKeysymToKeycode(otk::OBDisplay::display, sym)))
|
if (!(b.key = XKeysymToKeycode(otk::OBDisplay::display, sym)))
|
||||||
printf(_("No valid keycode for Key in key binding: %s\n"), key.c_str());
|
printf(_("No valid keycode for Key in key binding: %s\n"), key.c_str());
|
||||||
return b.key != 0;
|
return b.key != 0;
|
||||||
|
} else {
|
||||||
|
return buttonvalue(key, &b.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroytree(BindingTree *tree)
|
static void destroytree(BindingTree *tree)
|
||||||
|
|
|
@ -63,7 +63,6 @@ private:
|
||||||
otk::OBTimer _timer;
|
otk::OBTimer _timer;
|
||||||
|
|
||||||
PyObject *find(BindingTree *search, bool *conflict) const;
|
PyObject *find(BindingTree *search, bool *conflict) const;
|
||||||
bool translate(const std::string &str, Binding &b) const;
|
|
||||||
BindingTree *buildtree(const StringVect &keylist, PyObject *callback) const;
|
BindingTree *buildtree(const StringVect &keylist, PyObject *callback) const;
|
||||||
void assimilate(BindingTree *node);
|
void assimilate(BindingTree *node);
|
||||||
|
|
||||||
|
@ -75,6 +74,9 @@ public:
|
||||||
//! Destroys the OBBinding object
|
//! Destroys the OBBinding object
|
||||||
virtual ~OBBindings();
|
virtual ~OBBindings();
|
||||||
|
|
||||||
|
//! Translates a binding string into the actual Binding
|
||||||
|
bool translate(const std::string &str, Binding &b, bool askey = true) const;
|
||||||
|
|
||||||
//! Adds a new key binding
|
//! Adds a new key binding
|
||||||
/*!
|
/*!
|
||||||
A binding will fail to be added if the binding already exists (as part of
|
A binding will fail to be added if the binding already exists (as part of
|
||||||
|
|
41
src/frame.cc
41
src/frame.cc
|
@ -13,6 +13,8 @@ extern "C" {
|
||||||
#include "openbox.hh"
|
#include "openbox.hh"
|
||||||
#include "frame.hh"
|
#include "frame.hh"
|
||||||
#include "client.hh"
|
#include "client.hh"
|
||||||
|
#include "python.hh"
|
||||||
|
#include "bindings.hh"
|
||||||
#include "otk/display.hh"
|
#include "otk/display.hh"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -70,33 +72,26 @@ OBFrame::~OBFrame()
|
||||||
|
|
||||||
void OBFrame::grabButtons(bool grab)
|
void OBFrame::grabButtons(bool grab)
|
||||||
{
|
{
|
||||||
if (grab) {
|
_plate.grabButtons(grab);
|
||||||
// grab simple button clicks on the client, but pass them through too
|
|
||||||
otk::OBDisplay::grabButton(Button1, 0, _plate.window(), true,
|
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
|
||||||
_plate.window(), None, false);
|
|
||||||
otk::OBDisplay::grabButton(Button2, 0, _plate.window(), true,
|
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
|
||||||
_plate.window(), None, false);
|
|
||||||
otk::OBDisplay::grabButton(Button3, 0, _plate.window(), true,
|
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
|
||||||
_plate.window(), None, false);
|
|
||||||
otk::OBDisplay::grabButton(Button4, 0, _plate.window(), true,
|
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
|
||||||
_plate.window(), None, false);
|
|
||||||
otk::OBDisplay::grabButton(Button5, 0, _plate.window(), true,
|
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
|
||||||
_plate.window(), None, false);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
|
|
||||||
// grab any requested buttons on the entire frame
|
// grab any requested buttons on the entire frame
|
||||||
|
std::vector<std::string> grabs;
|
||||||
|
if (python_get_stringlist("client_buttons", &grabs)) {
|
||||||
|
std::vector<std::string>::iterator grab_it, grab_end = grabs.end();
|
||||||
|
for (grab_it = grabs.begin(); grab_it != grab_end; ++grab_it) {
|
||||||
|
Binding b(0,0);
|
||||||
|
if (!Openbox::instance->bindings()->translate(*grab_it, b, false))
|
||||||
|
continue;
|
||||||
|
printf("grabbing %d %d\n", b.key, b.modifiers);
|
||||||
if (grab) {
|
if (grab) {
|
||||||
|
otk::OBDisplay::grabButton(b.key, b.modifiers, _window, true,
|
||||||
otk::OBDisplay::grabButton(Button1, 0, _plate.window(), true,
|
ButtonPressMask | ButtonMotionMask |
|
||||||
ButtonPressMask, GrabModeSync, GrabModeSync,
|
ButtonReleaseMask, GrabModeAsync,
|
||||||
_plate.window(), None, false);
|
GrabModeAsync, _window, None, false);
|
||||||
} else {
|
} else {
|
||||||
|
otk::OBDisplay::ungrabButton(b.key, b.modifiers, _window);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,8 @@ Openbox::Openbox(int argc, char **argv)
|
||||||
// load config values
|
// load config values
|
||||||
python_exec(SCRIPTDIR"/config.py"); // load openbox config values
|
python_exec(SCRIPTDIR"/config.py"); // load openbox config values
|
||||||
// run all of the python scripts
|
// run all of the python scripts
|
||||||
python_exec(SCRIPTDIR"/clientmotion.py"); // moving and resizing clients
|
// python_exec(SCRIPTDIR"/clientmotion.py"); // moving and resizing clients
|
||||||
python_exec(SCRIPTDIR"/clicks.py"); // titlebar/root clicks and dblclicks
|
// python_exec(SCRIPTDIR"/clicks.py"); // titlebar/root clicks and dblclicks
|
||||||
// run the user's script
|
// run the user's script
|
||||||
python_exec(_scriptfilepath.c_str());
|
python_exec(_scriptfilepath.c_str());
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
%inline %{
|
%inline %{
|
||||||
enum ActionType {
|
enum ActionType {
|
||||||
Action_ButtonPress,
|
Action_ButtonPress,
|
||||||
Action_ButtonRelease,
|
|
||||||
Action_Click,
|
Action_Click,
|
||||||
Action_DoubleClick,
|
Action_DoubleClick,
|
||||||
Action_EnterWindow,
|
Action_EnterWindow,
|
||||||
|
|
|
@ -780,7 +780,6 @@ static std::string SwigString_AsString(PyObject* o) {
|
||||||
|
|
||||||
enum ActionType {
|
enum ActionType {
|
||||||
Action_ButtonPress,
|
Action_ButtonPress,
|
||||||
Action_ButtonRelease,
|
|
||||||
Action_Click,
|
Action_Click,
|
||||||
Action_DoubleClick,
|
Action_DoubleClick,
|
||||||
Action_EnterWindow,
|
Action_EnterWindow,
|
||||||
|
@ -850,6 +849,10 @@ PyObject * unregister_all(int action)
|
||||||
|
|
||||||
PyObject * bind(PyObject *keylist, PyObject *func)
|
PyObject * bind(PyObject *keylist, PyObject *func)
|
||||||
{
|
{
|
||||||
|
if (!PyCallable_Check(func)) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (!PyList_Check(keylist)) {
|
if (!PyList_Check(keylist)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
|
PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2913,7 +2916,6 @@ _swigt__p_XUnmapEvent,
|
||||||
|
|
||||||
static swig_const_info swig_const_table[] = {
|
static swig_const_info swig_const_table[] = {
|
||||||
{ SWIG_PY_INT, (char *)"Action_ButtonPress", (long) Action_ButtonPress, 0, 0, 0},
|
{ SWIG_PY_INT, (char *)"Action_ButtonPress", (long) Action_ButtonPress, 0, 0, 0},
|
||||||
{ SWIG_PY_INT, (char *)"Action_ButtonRelease", (long) Action_ButtonRelease, 0, 0, 0},
|
|
||||||
{ SWIG_PY_INT, (char *)"Action_Click", (long) Action_Click, 0, 0, 0},
|
{ SWIG_PY_INT, (char *)"Action_Click", (long) Action_Click, 0, 0, 0},
|
||||||
{ SWIG_PY_INT, (char *)"Action_DoubleClick", (long) Action_DoubleClick, 0, 0, 0},
|
{ SWIG_PY_INT, (char *)"Action_DoubleClick", (long) Action_DoubleClick, 0, 0, 0},
|
||||||
{ SWIG_PY_INT, (char *)"Action_EnterWindow", (long) Action_EnterWindow, 0, 0, 0},
|
{ SWIG_PY_INT, (char *)"Action_EnterWindow", (long) Action_EnterWindow, 0, 0, 0},
|
||||||
|
|
Loading…
Reference in a new issue