all repos — openbox @ 5face4c6f35172761367f63ac0b6eaf62d84e532

openbox fork - make it a bit more like ryudo

use otk objects in the ob scripts by importing otk
Dana Jansens danakj@orodu.net
commit

5face4c6f35172761367f63ac0b6eaf62d84e532

parent

5168a8add5ed46f74b615ecc60738c1113606734

M otk/Makefile.amotk/Makefile.am

@@ -1,4 +1,5 @@

buttonsdir = $(pkgdatadir)/buttons +scriptdir = $(libdir)/openbox/python CXXFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CXXFLAGS@ \ -DBUTTONSDIR=\"$(buttonsdir)\"

@@ -6,7 +7,7 @@

INCLUDES= -I../src #noinst_LIBRARIES=libotk.a -noinst_LTLIBRARIES=libotk.la +lib_LTLIBRARIES=libotk.la libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.cc \ renderstyle.cc rendercolor.cc \

@@ -15,13 +16,17 @@ property.cc rect.cc screeninfo.cc \

timer.cc \ configuration.cc util.cc widget.cc focuswidget.cc \ button.cc eventhandler.cc eventdispatcher.cc ustring.cc \ - label.cc focuslabel.cc application.cc appwidget.cc -# otk_wrap.cc + label.cc focuslabel.cc application.cc appwidget.cc \ + otk_wrap.cc libotk_la_LDFLAGS = $(XFT_LIBS) $(PYTHON_LIBS) @LIBS@ MAINTAINERCLEANFILES= Makefile.in +script_DATA = otk.py + +EXTRA_DIST = $(script_DATA) + distclean-local: rm -f *\~ *.orig *.rej .\#*

@@ -31,68 +36,10 @@

rendertest: libotk.la rendertest.cc $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o $@ rendertest.cc $(XFT_LIBS) .libs/libotk.al @LIBS@ -#otk.i: $(wildcard *.hh) -# touch $@ +otk.i: $(wildcard *.hh) + touch $@ -#otk_wrap.cc: otk.i -# swig $(filter -I%,$(CXXFLAGS)) -python -shadow -c++ -o $@ $< +%_wrap.cc: %.i + swig -c $(filter -I%,$(CXXFLAGS)) -python -shadow -c++ -nodefault -o $@ $< # local dependencies -application.o: application.cc application.hh eventdispatcher.hh \ - eventhandler.hh display.hh configuration.hh \ - timer.hh image.hh color.hh screeninfo.hh rect.hh \ - point.hh style.hh font.hh texture.hh util.hh widget.hh -appwidget.o: appwidget.cc appwidget.hh widget.hh rect.hh point.hh \ - texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \ - timer.hh configuration.hh eventdispatcher.hh eventhandler.hh \ - application.hh display.hh -button.o: button.cc button.hh focuslabel.hh focuswidget.hh widget.hh \ - rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \ - image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \ - eventhandler.hh application.hh display.hh -color.o: color.cc color.hh display.hh screeninfo.hh rect.hh point.hh -configuration.o: configuration.cc configuration.hh util.hh -eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh \ - eventhandler.hh display.hh -eventhandler.o: eventhandler.cc eventhandler.hh -focuslabel.o: focuslabel.cc focuslabel.hh focuswidget.hh widget.hh \ - rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \ - image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \ - eventhandler.hh application.hh display.hh -focuswidget.o: focuswidget.cc focuswidget.hh widget.hh rect.hh \ - point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \ - screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \ - eventhandler.hh application.hh display.hh -font.o: font.cc font.hh util.hh display.hh color.hh screeninfo.hh \ - rect.hh point.hh -gccache.o: gccache.cc gccache.hh display.hh color.hh assassin.hh \ - screeninfo.hh rect.hh point.hh -image.o: image.cc display.hh gccache.hh color.hh image.hh \ - screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh -imagecontrol.o: imagecontrol.cc display.hh color.hh image.hh \ - screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh -label.o: label.cc label.hh widget.hh rect.hh point.hh texture.hh \ - color.hh util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \ - configuration.hh eventdispatcher.hh eventhandler.hh application.hh \ - display.hh -otk_test.o: otk_test.cc application.hh eventdispatcher.hh \ - eventhandler.hh display.hh configuration.hh \ - timer.hh image.hh color.hh screeninfo.hh rect.hh \ - point.hh style.hh font.hh texture.hh util.hh focuswidget.hh widget.hh \ - appwidget.hh button.hh focuslabel.hh -property.o: property.cc property.hh screeninfo.hh rect.hh point.hh \ - display.hh -rect.o: rect.cc rect.hh point.hh -screeninfo.o: screeninfo.cc screeninfo.hh rect.hh point.hh display.hh \ - util.hh -style.o: style.cc display.hh util.hh style.hh color.hh font.hh \ - texture.hh image.hh screeninfo.hh rect.hh point.hh timer.hh \ - configuration.hh -texture.o: texture.cc texture.hh color.hh util.hh display.hh image.hh \ - screeninfo.hh rect.hh point.hh timer.hh -timer.o: timer.cc timer.hh -util.o: util.cc util.hh -widget.o: widget.cc widget.hh rect.hh point.hh texture.hh color.hh \ - util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \ - configuration.hh eventdispatcher.hh eventhandler.hh application.hh \ - display.hh assassin.hh
M otk/otk.iotk/otk.i

@@ -14,35 +14,40 @@ %include "stl.i"

//%include std_list.i %include "ustring.i" -%ignore otk::OBDisplay::display; +%ignore otk::display; +%inline %{ + otk::Display *Display_instance() { return otk::display; } +%}; + +%ignore otk::Property::atoms; %inline %{ - Display *OBDisplay_display() { return otk::OBDisplay::display; } + const otk::Atoms& Property_atoms() { return otk::Property::atoms; } %}; namespace otk { -%rename(setValue_bool) Configuration::setValue(std::string const &,bool); +/*%rename(setValue_bool) Configuration::setValue(std::string const &,bool); %rename(setValue_unsigned) Configuration::setValue(const std::string &, unsigned int); %rename(setValue_long) Configuration::setValue(const std::string &, long); %rename(setValue_unsignedlong) Configuration::setValue(const std::string &, unsigned long); %rename(setValue_string) Configuration::setValue(const std::string &, const std::string &); -%rename(setValue_charptr) Configuration::setValue(const std::string &, const char *); +%rename(setValue_charptr) Configuration::setValue(const std::string &, const char *);*/ %rename(itostring_unsigned) itostring(unsigned int); %rename(itostring_long) itostring(long); %rename(itostring_unsigned_long) itostring(unsigned long); // these are needed for guile, but not needed for python! -%rename(equals) BColor::operator==; -%rename(equals) Rect::operator==; -%rename(equals) BTexture::operator==; -%ignore BColor::operator!=; -%ignore BTexture::operator!=; +//%rename(equals) BColor::operator==; +//%rename(equals) Rect::operator==; +//%rename(equals) BTexture::operator==; +//%ignore BColor::operator!=; +//%ignore BTexture::operator!=; %ignore Rect::operator!=; %ignore Rect::operator|; %ignore Rect::operator|=; %ignore Rect::operator&; %ignore Rect::operator&=; -%ignore OBTimer::operator<; +//%ignore OBTimer::operator<; %ignore TimerLessThan; /*

@@ -52,8 +57,13 @@ %rename(set_string_multi) OtkProperty::set(Window, Atoms, StringType, const StringVect &);

*/ } +%include "eventhandler.hh" %include "eventdispatcher.hh" -%include "eventhandler.hh" +%include "point.hh" +%include "rect.hh" +%include "rendercolor.hh" +%include "rendertexture.hh" +%include "renderstyle.hh" %include "widget.hh" %include "focuswidget.hh" %include "focuslabel.hh"

@@ -61,23 +71,16 @@ %include "appwidget.hh"

%include "application.hh" %include "assassin.hh" %include "button.hh" -%include "color.hh" -%include "configuration.hh" +//%include "configuration.hh" %include "display.hh" %include "font.hh" -%include "gccache.hh" -%include "image.hh" +%include "rendercontrol.hh" %include "label.hh" -%include "point.hh" %include "property.hh" -%include "rect.hh" %include "screeninfo.hh" %include "strut.hh" -%include "style.hh" -%include "texture.hh" %include "timer.hh" %include "util.hh" -%include "widget.hh" // for Mod1Mask etc %include "X11/X.h"
M otk/rendercolor.hhotk/rendercolor.hh

@@ -10,20 +10,19 @@ #include <map>

namespace otk { +struct RGB { + int r; + int g; + int b; + RGB(int red, int green, int blue) : r(red), g(green), b(blue) {} + // color is in ARGB format + RGB(unsigned long color) + : r((color >> 16) & 0xff), + g((color >> 8) & 0xff), + b((color) & 0xff) {} +}; + class RenderColor { -public: - struct RGB { - int r; - int g; - int b; - RGB(int red, int green, int blue) : r(red), g(green), b(blue) {} - // color is in ARGB format - RGB(unsigned long color) - : r((color >> 16) & 0xff), - g((color >> 8) & 0xff), - b((color) & 0xff) {} - }; - private: struct CacheItem { GC gc;
M otk/rendertexture.hhotk/rendertexture.hh

@@ -70,10 +70,10 @@ public:

RenderTexture(int screen, bool parent_relative, ReliefType relief, BevelType bevel, bool border, GradientType gradient, bool interlaced, - const RenderColor::RGB &color, - const RenderColor::RGB &secondary_color, - const RenderColor::RGB &border_color, - const RenderColor::RGB &interlace_color) + const RGB &color, + const RGB &secondary_color, + const RGB &border_color, + const RGB &interlace_color) : _screen(screen), _parent_relative(parent_relative), _relief(relief),
M scripts/callbacks.pyscripts/callbacks.py

@@ -1,35 +1,45 @@

-########################################################################### -### Functions that can be used as callbacks for mouse/keyboard bindings ### -########################################################################### +############################################################################ +### Functions that can be used as callbacks for mouse/keyboard bindings ### +############################################################################ + +############################################################################# +### Options that can be modified to change the default hooks' behaviors. ### +### ### +# resize_nearest - 1 to resize from the corner nearest where the mouse ### +### is, 0 to resize always from the bottom right corner. ### +resize_nearest = 1 ### +### ### +############################################################################# import ob +import otk def state_above(data, add=2): """Toggles, adds or removes the 'above' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_above) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_above) def state_below(data, add=2): """Toggles, adds or removes the 'below' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_below) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_below) def state_shaded(data, add=2): """Toggles, adds or removes the 'shaded' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_shaded) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_shaded) def iconify(data): """Iconifies the window on which the event occured""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().wm_change_state, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().wm_change_state, data.client.window(), 3) # IconicState def restore(data):

@@ -37,15 +47,15 @@ """Un-iconifies the window on which the event occured, but does not focus

if. If you want to focus the window too, it is recommended that you use the activate() function.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().wm_change_state, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().wm_change_state, data.client.window(), 1) # NormalState def close(data): """Closes the window on which the event occured""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_close_window, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_close_window, data.client.window(), 0) def focus(data):

@@ -83,23 +93,23 @@ dy = data.yroot - py

# pick a corner to anchor if not (resize_nearest or data.context == MC_Grip): - corner = Client.TopLeft + corner = ob.Client.TopLeft else: x = px - data.press_clientx y = py - data.press_clienty if y < data.press_clientheight / 2: if x < data.press_clientwidth / 2: - corner = Client.BottomRight + corner = ob.Client.BottomRight dx *= -1 else: - corner = Client.BottomLeft + corner = ob.Client.BottomLeft dy *= -1 else: if x < data.press_clientwidth / 2: - corner = Client.TopRight + corner = ob.Client.TopRight dx *= -1 else: - corner = Client.TopLeft + corner = ob.Client.TopLeft data.client.resize(corner, data.press_clientwidth + dx,

@@ -133,8 +143,8 @@ state_shaded(data, 0)

def change_desktop(data, num): """Switches to a specified desktop""" - root = ob.display.screenInfo(data.screen).rootWindow() - ob.send_client_msg(root, ob.Property_atoms().net_current_desktop, + root = otk.display.screenInfo(data.screen).rootWindow() + ob.send_client_msg(root, otk.Property_atoms().net_current_desktop, root, num) def next_desktop(data, no_wrap=0):

@@ -164,8 +174,8 @@

def send_to_desktop(data, num): """Sends a client to a specified desktop""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_desktop, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_desktop, data.client.window(),num) def toggle_all_desktops(data):
M scripts/config.pyscripts/config.py

@@ -30,15 +30,5 @@ # number_of_desktops - the number of desktops/workspaces which can be scrolled

# between. number_of_desktops = 4 -############################################################################# -### Options that can be modified by the user to change the default hooks' ### -### behaviors. ### -############################################################################# - -# resize_nearest - 1 to resize from the corner nearest where the mouse is, 0 -# to resize always from the bottom right corner. -resize_nearest = 1 - - print "Loaded config.py"
M scripts/windowplacement.pyscripts/windowplacement.py

@@ -3,6 +3,7 @@ ### Window placement algorithms, choose one of these and ebind it to the ###

### ob.EventAction.PlaceWindow event. ### ############################################################################ +import otk import ob import random

@@ -13,6 +14,8 @@ if not data.client: return

client_area = data.client.area() frame_size = data.client.frame.size() screen_area = ob.openbox.screen(data.screen).area() + print str(screen_area.x()) + " " + str(screen_area.y()) + " " + \ + str(screen_area.width()) + " " + str(screen_area.height()) width = screen_area.width() - (client_area.width() + frame_size.left + frame_size.right) height = screen_area.height() - (client_area.height() +
M src/Makefile.amsrc/Makefile.am

@@ -15,7 +15,7 @@ INCLUDES= -I..

bin_PROGRAMS= openbox3 -openbox3_LDADD=-L../otk -lotk @LIBINTL@ +openbox3_LDADD=-L../otk -lotk -lswigpy @LIBINTL@ openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \ main.cc backgroundwidget.cc labelwidget.cc \

@@ -35,7 +35,7 @@

openbox.i: openbox.hh screen.hh client.hh python.hh frame.hh touch $@ -openbox_wrap.cc: openbox.i - swig -I../otk $(filter -I%,$(CXXFLAGS)) -python -shadow -c++ -nodefault -o $@ $< +%_wrap.cc: %.i + swig -c -I../otk $(filter -I%,$(CXXFLAGS)) -python -shadow -c++ -nodefault -o $@ $< # local dependencies
M src/client.ccsrc/client.cc

@@ -575,8 +575,8 @@ if (num == 4) {

_strut.left = data[0]; _strut.right = data[1]; _strut.top = data[2]; - _strut.bottom = data[3]; - + _strut.bottom = data[3]; + openbox->screen(_screen)->updateStrut(); }
M src/openbox.isrc/openbox.i

@@ -110,6 +110,7 @@ return (int) self->clients.size();

} }; +/* %include "../otk/ustring.i" %ignore otk::display;

@@ -133,6 +134,9 @@ %include "../otk/eventhandler.hh"

%include "../otk/eventdispatcher.hh" %import "../otk/widget.hh" +*/ +%import "../otk/otk.i" + %import "widgetbase.hh" %import "actions.hh"
M src/python.ccsrc/python.cc

@@ -9,8 +9,9 @@ #include "otk/display.hh"

#include "otk/util.hh" extern "C" { -// The initializer in openbox_wrap.cc +// The initializer in openbox_wrap.cc / otk_wrap.cc extern void init_ob(void); +extern void init_otk(void); } namespace ob {

@@ -23,6 +24,7 @@ // start the python engine

Py_SetProgramName(argv0); Py_Initialize(); // initialize the C python module + init_otk(); init_ob(); // include the openbox directories for python scripts in the sys path PyRun_SimpleString("import sys");

@@ -30,10 +32,10 @@ PyRun_SimpleString(const_cast<char*>(("sys.path.append('" +

otk::expandTilde("~/.openbox/python") + "')").c_str())); PyRun_SimpleString("sys.path.append('" SCRIPTDIR "')"); - PyRun_SimpleString("import ob;"); + PyRun_SimpleString("import ob; import otk;"); // set up convenience global variables PyRun_SimpleString("ob.openbox = ob.Openbox_instance()"); - PyRun_SimpleString("ob.display = ob.Display_instance()"); + PyRun_SimpleString("otk.display = otk.Display_instance()"); // set up access to the python global variables PyObject *obmodule = PyImport_AddModule("config");
M src/screen.ccsrc/screen.cc

@@ -261,7 +261,7 @@ }

#endif // XINERAMA */ - if (old_area != _area) + //if (old_area != _area) // XXX: re-maximize windows changeWorkArea();