all repos — openbox @ 7f590e53607ef1592d65a425b9cdcaa181912465

openbox fork - make it a bit more like ryudo

pointer's variables are config vars
Dana Jansens danakj@orodu.net
commit

7f590e53607ef1592d65a425b9cdcaa181912465

parent

74c683ee5fb232d7fe9f517b21ffd9ee50872dce

M doc/python/config.txtdoc/python/config.txt

@@ -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'
M openbox/Makefile.amopenbox/Makefile.am

@@ -20,12 +20,12 @@ ob3_LDADD=@LIBINTL@ ../render/librender.a

ob3_LDFLAGS=-export-dynamic 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 \ - 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 \ 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 \ - engine.h + engine.h configwrap.h MAINTAINERCLEANFILES= Makefile.in
A openbox/configwrap.c

@@ -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); +}
A openbox/configwrap.h

@@ -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
M openbox/openbox.copenbox/openbox.c

@@ -14,6 +14,7 @@ #include "python.h"

#include "hooks.h" #include "clientwrap.h" #include "openboxwrap.h" +#include "configwrap.h" #include "themerc.h" #include "timer.h" #include "../render/render.h"

@@ -133,6 +134,7 @@ font_startup();

themerc_startup(); engine_startup(themerc_engine); python_startup(); + configwrap_startup(); openboxwrap_startup(); clientwrap_startup(); hooks_startup();

@@ -170,6 +172,7 @@ event_shutdown();

hooks_shutdown(); clientwrap_shutdown(); openboxwrap_shutdown(); + configwrap_shutdown(); python_shutdown(); engine_shutdown(); themerc_shutdown();
M openbox/pointer.copenbox/pointer.c

@@ -4,6 +4,7 @@ #include "frame.h"

#include "engine.h" #include "openbox.h" #include "hooks.h" +#include "configwrap.h" #include <glib.h> #include <Python.h>

@@ -24,7 +25,6 @@

/* GData of GSList*s of PointerBinding*s. */ static GData *bound_contexts; static gboolean grabbed; -static int double_click_rate, drag_threshold; PyObject *grab_func; struct foreach_grab_temp {

@@ -332,6 +332,9 @@ GString *str = g_string_sized_new(0);

guint state; GSList *it = NULL; PointerBinding *b = NULL; + guint drag_threshold; + + drag_threshold = configwrap_get_int("input", "drag_threshold"); contextq = engine_get_context(c, e->xany.window);

@@ -388,8 +391,8 @@ case ButtonRelease:

if (button == e->xbutton.button) { /* determine if this is a valid 'click'. Its not if the release is not over the window, or if a drag occured. */ - if (ABS(e->xbutton.x_root - pressx) < (unsigned)drag_threshold && - ABS(e->xbutton.y_root - pressy) < (unsigned)drag_threshold && + if (ABS(e->xbutton.x_root - pressx) < drag_threshold && + ABS(e->xbutton.y_root - pressy) < drag_threshold && e->xbutton.x >= 0 && e->xbutton.y >= 0) { int junk; Window wjunk;

@@ -403,7 +406,8 @@

/* determine if this is a valid 'double-click' */ if (click) { if (lastbutton == button && - e->xbutton.time - double_click_rate < time) { + e->xbutton.time - + configwrap_get_int("input", "double_click_rate") < time) { dblclick = TRUE; lastbutton = 0; } else

@@ -432,8 +436,8 @@ client, b == NULL ? NULL : b->funcs[Action_Release]);

break; case MotionNotify: /* watch out for the drag threshold */ - if (ABS(e->xmotion.x_root - pressx) < (unsigned)drag_threshold && - ABS(e->xmotion.y_root - pressy) < (unsigned)drag_threshold) + if (ABS(e->xmotion.x_root - pressx) < drag_threshold && + ABS(e->xmotion.y_root - pressy) < drag_threshold) break; fire_event(str->str, contextq, Action_Motion, state, button, e->xmotion.x_root,

@@ -690,8 +694,15 @@ PyObject *input, *inputdict;

Pointer *ptr; grabbed = FALSE; - double_click_rate = 300; - drag_threshold = 3; + configwrap_add_int("input", "double_click_rate", "Double-Click Rate", + "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); PointerType.ob_type = &PyType_Type;
M python/config.pypython/config.py

@@ -186,57 +186,5 @@ 'function',# Function types hold any callable 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"
M python/rc.pypython/rc.py

@@ -2,6 +2,9 @@ import hooks, ob, keymap, buttonmap, os, sys, input, motion, historyplacement

import stackedcycle from input import Pointer +import config +print dir(config) + hooks.managed.append(historyplacement.place) _grab = 0