pointer's variables are config vars
This commit is contained in:
parent
74c683ee5f
commit
7f590e5360
8 changed files with 177 additions and 62 deletions
|
@ -11,3 +11,58 @@ Methods
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
add(modulename, name, friendlyname, description, type, default, **keywords):
|
||||||
|
|
||||||
|
Add a variable to the configuration system for a module.
|
||||||
|
|
||||||
|
modulename: The name of the module, e.g. 'focus'
|
||||||
|
name: The name of the variable, e.g. 'my_variable'
|
||||||
|
friendlyname: The user-friendly name of the variable, e.g.
|
||||||
|
'My Variable'
|
||||||
|
description: The detailed destription of the variable, e.g.
|
||||||
|
'Does Things'
|
||||||
|
type: The type of the variable, one of:
|
||||||
|
* 'boolean'
|
||||||
|
* 'enum'
|
||||||
|
* 'integer'
|
||||||
|
* 'string'
|
||||||
|
* 'function'
|
||||||
|
* 'object'
|
||||||
|
default: The default value for the variable, e.g. 300
|
||||||
|
keywords: Extra keyword=value pairs to further define the variable.
|
||||||
|
These can be:
|
||||||
|
* For 'enum' types:
|
||||||
|
* options : A list of possible options for the variable.
|
||||||
|
This *must* be set for all enum variables.
|
||||||
|
* For 'integer' types:
|
||||||
|
* min : The minimum value for the variable.
|
||||||
|
* max : The maximum value for the variable.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
set(modulename, name, value):
|
||||||
|
|
||||||
|
Sets the value for a variable of the specified module.
|
||||||
|
|
||||||
|
modulename: The name of the module, e.g. 'focus'
|
||||||
|
name: The name of the variable, e.g. 'my_variable'
|
||||||
|
value: The new value for the variable.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
reset(modulename, name):
|
||||||
|
|
||||||
|
Resets the value for a variable in the specified module back to its original
|
||||||
|
(default) value.
|
||||||
|
|
||||||
|
modulename: The name of the module, e.g. 'focus'
|
||||||
|
name: The name of the variable, e.g. 'my_variable'
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
get(modulename, name):
|
||||||
|
|
||||||
|
Returns the current value for a variable in the specified module.
|
||||||
|
|
||||||
|
modulename: The name of the module, e.g. 'focus'
|
||||||
|
name: The name of the variable, e.g. 'my variable'
|
||||||
|
|
|
@ -20,12 +20,12 @@ ob3_LDADD=@LIBINTL@ ../render/librender.a
|
||||||
ob3_LDFLAGS=-export-dynamic
|
ob3_LDFLAGS=-export-dynamic
|
||||||
ob3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c prop.c \
|
ob3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c prop.c \
|
||||||
python.c screen.c stacking.c xerror.c hooks.c themerc.c timer.c \
|
python.c screen.c stacking.c xerror.c hooks.c themerc.c timer.c \
|
||||||
clientwrap.c openboxwrap.c pointer.c keyboard.c engine.c
|
clientwrap.c openboxwrap.c pointer.c keyboard.c engine.c configwrap.c
|
||||||
|
|
||||||
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
||||||
openbox.h prop.h python.h screen.h stacking.h xerror.h themerc.h \
|
openbox.h prop.h python.h screen.h stacking.h xerror.h themerc.h \
|
||||||
timer.h hooks.h clientwrap.h openboxwrap.h pointer.h keyboard.h \
|
timer.h hooks.h clientwrap.h openboxwrap.h pointer.h keyboard.h \
|
||||||
engine.h
|
engine.h configwrap.h
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
|
|
80
openbox/configwrap.c
Normal file
80
openbox/configwrap.c
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
#include <Python.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
/* This simply wraps the config.py module so that it can be accessed from the
|
||||||
|
C code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static PyObject *add, *get, *set, *reset;
|
||||||
|
|
||||||
|
void configwrap_startup()
|
||||||
|
{
|
||||||
|
PyObject *c, *cdict;
|
||||||
|
|
||||||
|
/* get the ob module/dict */
|
||||||
|
c = PyImport_ImportModule("config"); /* new */
|
||||||
|
g_assert(c != NULL);
|
||||||
|
cdict = PyModule_GetDict(c); /* borrowed */
|
||||||
|
g_assert(cdict != NULL);
|
||||||
|
|
||||||
|
/* get the functions */
|
||||||
|
add = PyDict_GetItemString(cdict, "add");
|
||||||
|
g_assert(add != NULL);
|
||||||
|
get = PyDict_GetItemString(cdict, "get");
|
||||||
|
g_assert(get != NULL);
|
||||||
|
set = PyDict_GetItemString(cdict, "set");
|
||||||
|
g_assert(set != NULL);
|
||||||
|
reset = PyDict_GetItemString(cdict, "reset");
|
||||||
|
g_assert(reset != NULL);
|
||||||
|
|
||||||
|
Py_DECREF(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void configwrap_shutdown()
|
||||||
|
{
|
||||||
|
Py_DECREF(get);
|
||||||
|
Py_DECREF(set);
|
||||||
|
Py_DECREF(reset);
|
||||||
|
Py_DECREF(add);
|
||||||
|
}
|
||||||
|
|
||||||
|
void configwrap_add_int(char *modname, char *varname, char *friendname,
|
||||||
|
char *description, int defvalue)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
r= PyObject_CallFunction(add, "sssssi", modname, varname,
|
||||||
|
friendname, description, "integer", defvalue);
|
||||||
|
g_assert(r != NULL);
|
||||||
|
Py_DECREF(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
int configwrap_get_int(char *modname, char *varname)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
r = PyObject_CallFunction(get, "ss", modname, varname);
|
||||||
|
g_assert(r != NULL);
|
||||||
|
i = PyInt_AsLong(r);
|
||||||
|
Py_DECREF(r);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void configwrap_set_int(char *modname, char *varname, int value)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
r = PyObject_CallFunction(set, "ssi", modname, varname, value);
|
||||||
|
g_assert(r != NULL);
|
||||||
|
Py_DECREF(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void configwrap_reset(char *modname, char *varname)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
r = PyObject_CallFunction(reset, "ss", modname, varname);
|
||||||
|
g_assert(r != NULL);
|
||||||
|
Py_DECREF(r);
|
||||||
|
}
|
15
openbox/configwrap.h
Normal file
15
openbox/configwrap.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef __configwrap_h
|
||||||
|
#define __configwrap_h
|
||||||
|
|
||||||
|
void configwrap_startup();
|
||||||
|
void configwrap_shutdown();
|
||||||
|
|
||||||
|
void configwrap_add_int(char *modname, char *varname, char *friendname,
|
||||||
|
char *description, int defvalue);
|
||||||
|
int configwrap_get_int(char *modname, char *varname);
|
||||||
|
void configwrap_set_int(char *modname, char *varname, int value);
|
||||||
|
|
||||||
|
|
||||||
|
void configwrap_reset(char *modname, char *varname);
|
||||||
|
|
||||||
|
#endif
|
|
@ -14,6 +14,7 @@
|
||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
#include "clientwrap.h"
|
#include "clientwrap.h"
|
||||||
#include "openboxwrap.h"
|
#include "openboxwrap.h"
|
||||||
|
#include "configwrap.h"
|
||||||
#include "themerc.h"
|
#include "themerc.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "../render/render.h"
|
#include "../render/render.h"
|
||||||
|
@ -133,6 +134,7 @@ int main(int argc, char **argv)
|
||||||
themerc_startup();
|
themerc_startup();
|
||||||
engine_startup(themerc_engine);
|
engine_startup(themerc_engine);
|
||||||
python_startup();
|
python_startup();
|
||||||
|
configwrap_startup();
|
||||||
openboxwrap_startup();
|
openboxwrap_startup();
|
||||||
clientwrap_startup();
|
clientwrap_startup();
|
||||||
hooks_startup();
|
hooks_startup();
|
||||||
|
@ -170,6 +172,7 @@ int main(int argc, char **argv)
|
||||||
hooks_shutdown();
|
hooks_shutdown();
|
||||||
clientwrap_shutdown();
|
clientwrap_shutdown();
|
||||||
openboxwrap_shutdown();
|
openboxwrap_shutdown();
|
||||||
|
configwrap_shutdown();
|
||||||
python_shutdown();
|
python_shutdown();
|
||||||
engine_shutdown();
|
engine_shutdown();
|
||||||
themerc_shutdown();
|
themerc_shutdown();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
|
#include "configwrap.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
@ -24,7 +25,6 @@ typedef enum {
|
||||||
/* GData of GSList*s of PointerBinding*s. */
|
/* GData of GSList*s of PointerBinding*s. */
|
||||||
static GData *bound_contexts;
|
static GData *bound_contexts;
|
||||||
static gboolean grabbed;
|
static gboolean grabbed;
|
||||||
static int double_click_rate, drag_threshold;
|
|
||||||
PyObject *grab_func;
|
PyObject *grab_func;
|
||||||
|
|
||||||
struct foreach_grab_temp {
|
struct foreach_grab_temp {
|
||||||
|
@ -332,6 +332,9 @@ void pointer_event(XEvent *e, Client *c)
|
||||||
guint state;
|
guint state;
|
||||||
GSList *it = NULL;
|
GSList *it = NULL;
|
||||||
PointerBinding *b = NULL;
|
PointerBinding *b = NULL;
|
||||||
|
guint drag_threshold;
|
||||||
|
|
||||||
|
drag_threshold = configwrap_get_int("input", "drag_threshold");
|
||||||
|
|
||||||
contextq = engine_get_context(c, e->xany.window);
|
contextq = engine_get_context(c, e->xany.window);
|
||||||
|
|
||||||
|
@ -388,8 +391,8 @@ void pointer_event(XEvent *e, Client *c)
|
||||||
if (button == e->xbutton.button) {
|
if (button == e->xbutton.button) {
|
||||||
/* determine if this is a valid 'click'. Its not if the release is
|
/* determine if this is a valid 'click'. Its not if the release is
|
||||||
not over the window, or if a drag occured. */
|
not over the window, or if a drag occured. */
|
||||||
if (ABS(e->xbutton.x_root - pressx) < (unsigned)drag_threshold &&
|
if (ABS(e->xbutton.x_root - pressx) < drag_threshold &&
|
||||||
ABS(e->xbutton.y_root - pressy) < (unsigned)drag_threshold &&
|
ABS(e->xbutton.y_root - pressy) < drag_threshold &&
|
||||||
e->xbutton.x >= 0 && e->xbutton.y >= 0) {
|
e->xbutton.x >= 0 && e->xbutton.y >= 0) {
|
||||||
int junk;
|
int junk;
|
||||||
Window wjunk;
|
Window wjunk;
|
||||||
|
@ -403,7 +406,8 @@ void pointer_event(XEvent *e, Client *c)
|
||||||
/* determine if this is a valid 'double-click' */
|
/* determine if this is a valid 'double-click' */
|
||||||
if (click) {
|
if (click) {
|
||||||
if (lastbutton == button &&
|
if (lastbutton == button &&
|
||||||
e->xbutton.time - double_click_rate < time) {
|
e->xbutton.time -
|
||||||
|
configwrap_get_int("input", "double_click_rate") < time) {
|
||||||
dblclick = TRUE;
|
dblclick = TRUE;
|
||||||
lastbutton = 0;
|
lastbutton = 0;
|
||||||
} else
|
} else
|
||||||
|
@ -432,8 +436,8 @@ void pointer_event(XEvent *e, Client *c)
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
/* watch out for the drag threshold */
|
/* watch out for the drag threshold */
|
||||||
if (ABS(e->xmotion.x_root - pressx) < (unsigned)drag_threshold &&
|
if (ABS(e->xmotion.x_root - pressx) < drag_threshold &&
|
||||||
ABS(e->xmotion.y_root - pressy) < (unsigned)drag_threshold)
|
ABS(e->xmotion.y_root - pressy) < drag_threshold)
|
||||||
break;
|
break;
|
||||||
fire_event(str->str, contextq, Action_Motion,
|
fire_event(str->str, contextq, Action_Motion,
|
||||||
state, button, e->xmotion.x_root,
|
state, button, e->xmotion.x_root,
|
||||||
|
@ -690,8 +694,15 @@ void pointer_startup()
|
||||||
Pointer *ptr;
|
Pointer *ptr;
|
||||||
|
|
||||||
grabbed = FALSE;
|
grabbed = FALSE;
|
||||||
double_click_rate = 300;
|
configwrap_add_int("input", "double_click_rate", "Double-Click Rate",
|
||||||
drag_threshold = 3;
|
"An integer containing the number of milliseconds in "
|
||||||
|
"which 2 clicks must be received to cause a "
|
||||||
|
"double-click event.", 300);
|
||||||
|
configwrap_add_int("input", "drag_threshold", "Drag Threshold",
|
||||||
|
"An integer containing the number of pixels a drag "
|
||||||
|
"must go before motion events start getting generated. "
|
||||||
|
"Once a drag has begun, the button release will not "
|
||||||
|
"count as a click event.", 3);
|
||||||
g_datalist_init(&bound_contexts);
|
g_datalist_init(&bound_contexts);
|
||||||
|
|
||||||
PointerType.ob_type = &PyType_Type;
|
PointerType.ob_type = &PyType_Type;
|
||||||
|
|
|
@ -186,57 +186,5 @@ _types = [ 'boolean', # Boolean types can only hold a value of 0 or 1.
|
||||||
|
|
||||||
'object' # Object types can hold any python object.
|
'object' # Object types can hold any python object.
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
### Options that can be changed to adjust the behavior of Openbox. ###
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
THEME = "/usr/local/share/openbox/styles/fieron2"
|
|
||||||
"""The theme used to decorate everything."""
|
|
||||||
|
|
||||||
#TITLEBAR_LAYOUT = [ "icon", "title", "alldesktops", "iconify", "maximize", "close" ]
|
|
||||||
TITLEBAR_LAYOUT = "DITMC"
|
|
||||||
"""The layout of the buttons/label on client titlebars, can be made up of the
|
|
||||||
following:
|
|
||||||
I - iconify button
|
|
||||||
L - text label
|
|
||||||
M - maximize button,
|
|
||||||
D - all-desktops button
|
|
||||||
C - close button
|
|
||||||
If no 'L' is included in the string, one will be added to the end by
|
|
||||||
Openbox."""
|
|
||||||
|
|
||||||
DOUBLE_CLICK_DELAY = 300
|
|
||||||
"""The number of milliseconds in which 2 clicks are perceived as a
|
|
||||||
double-click."""
|
|
||||||
|
|
||||||
DRAG_THRESHOLD = 3
|
|
||||||
"""The amount of pixels that you have to drag the mouse before motion events
|
|
||||||
will start occuring."""
|
|
||||||
|
|
||||||
DESKTOP_NAMES = ["one", "two", "three", "four", "five", "six", "seven", \
|
|
||||||
"eight", "nine", "ten", "eleven", "twelve"]
|
|
||||||
"""The name of each desktop."""
|
|
||||||
|
|
||||||
NUMBER_OF_DESKTOPS = 4
|
|
||||||
"""The number of desktops/workspaces which can be scrolled between."""
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
print "Loaded config.py"
|
print "Loaded config.py"
|
||||||
|
|
|
@ -2,6 +2,9 @@ import hooks, ob, keymap, buttonmap, os, sys, input, motion, historyplacement
|
||||||
import stackedcycle
|
import stackedcycle
|
||||||
from input import Pointer
|
from input import Pointer
|
||||||
|
|
||||||
|
import config
|
||||||
|
print dir(config)
|
||||||
|
|
||||||
hooks.managed.append(historyplacement.place)
|
hooks.managed.append(historyplacement.place)
|
||||||
|
|
||||||
_grab = 0
|
_grab = 0
|
||||||
|
|
Loading…
Reference in a new issue