]> Dogcows Code - chaz/openbox/commitdiff
use otk objects in the ob scripts by importing otk
authorDana Jansens <danakj@orodu.net>
Mon, 27 Jan 2003 13:42:41 +0000 (13:42 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 27 Jan 2003 13:42:41 +0000 (13:42 +0000)
12 files changed:
otk/Makefile.am
otk/otk.i
otk/rendercolor.hh
otk/rendertexture.hh
scripts/callbacks.py
scripts/config.py
scripts/windowplacement.py
src/Makefile.am
src/client.cc
src/openbox.i
src/python.cc
src/screen.cc

index c714f472fcdce059c66077a2671a4e350e945f77..29b35442fd9572d25ca3ae8cd6475f066021d1b9 100644 (file)
@@ -1,4 +1,5 @@
 buttonsdir = $(pkgdatadir)/buttons
+scriptdir = $(libdir)/openbox/python
 
 CXXFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CXXFLAGS@ \
 -DBUTTONSDIR=\"$(buttonsdir)\"
@@ -6,7 +7,7 @@ CXXFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CXXFLAGS@ \
 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 @@ libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.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 @@ otk_test: libotk.la otk_test.cc
 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
index bda7ce97125cfadc114af0167a5290295d1732a2..ed666e56f330ab847b07c6150c6e763bf55e61ed 100644 (file)
--- a/otk/otk.i
+++ b/otk/otk.i
 //%include std_list.i
 %include "ustring.i"
 
-%ignore otk::OBDisplay::display;
+%ignore otk::display;
 %inline %{
-  Display *OBDisplay_display() { return otk::OBDisplay::display; }
+  otk::Display *Display_instance() { return otk::display; }
+%};
+
+%ignore otk::Property::atoms;
+%inline %{
+  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 @@ namespace otk {
 */
 }
 
-%include "eventdispatcher.hh"
 %include "eventhandler.hh"
+%include "eventdispatcher.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 @@ namespace otk {
 %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"
index c5835385ddcb8465f7cfaec14c59784090a16ee6..8ed8ce5802e24eda0dd1031b5e7fd66d96a1d04a 100644 (file)
@@ -10,20 +10,19 @@ extern "C" {
 
 namespace otk {
 
-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) {}
-  };
+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 {
 private:
   struct CacheItem {
     GC gc;
index 8e588558f794363df29a5cebf799537ed21da775..54fbd9c26d3ed480ed9b67519cc3b9077b0f4671 100644 (file)
@@ -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),
index caea758632403802e0de5bd71e902ef1260e1e8c..1289a7bbf3a271c4dc1988d511aba83ec12ea0cd 100644 (file)
@@ -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 @@ def restore(data):
        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 @@ def resize(data):
 
     # 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 @@ def unshade(data):
 
 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 prev_desktop(data, no_wrap=0):
 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):
index e59360bee323aa41a23fba7bf6445cc42380c44e..823d9d3fd3db39b4b20c45cd373e9d519215db64 100644 (file)
@@ -30,15 +30,5 @@ desktop_names = ["one", "two", "three", "four", "five", "six", "seven", \
 #                      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"
index 127cd2ad1203cc70b0990e32c75977f761f07330..81d260e8188a65bef75f01aaeb2bdaf4b4caf469 100644 (file)
@@ -3,6 +3,7 @@
 ### ob.EventAction.PlaceWindow event.                                    ###
 ############################################################################
 
+import otk
 import ob
 import random
 
@@ -13,6 +14,8 @@ def random(data):
     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() + 
index e697fc45ef61d1419802852580fc4181a4bab6a4..0b35f72a6ca5f9bde7d6afabcc5251c6cc5994d3 100644 (file)
@@ -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 @@ distclean-local:
 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
index 2c3d3ad37cc7614d62ae7f29078a141e33b190f0..eeb09a374981a4fe5cfe9dc30d3f6386c6faa980 100644 (file)
@@ -575,8 +575,8 @@ void Client::updateStrut()
     _strut.left = data[0];
     _strut.right = data[1];
     _strut.top = data[2];
-    _strut.bottom = data[3];
-    
+    _strut.bottom = data[3]; 
+   
     openbox->screen(_screen)->updateStrut();
   }
 
index 7ab588e1c4516a751de50bcd75bf8a2aed1e2763..b3d1a9ed725650c70954521d4273298662011feb 100644 (file)
@@ -110,6 +110,7 @@ void python_callback(PyObject *func, KeyData *data)
   }
 };
 
+/*
 %include "../otk/ustring.i"
 
 %ignore otk::display;
@@ -133,6 +134,9 @@ void python_callback(PyObject *func, KeyData *data)
 %include "../otk/eventdispatcher.hh"
 
 %import "../otk/widget.hh"
+*/
+%import "../otk/otk.i"
+
 %import "widgetbase.hh"
 %import "actions.hh"
 
index f95d4723772f0b89e4af3ad38a82cd26c1fcdea4..a7e2eada9e086a63aab4408b7bb172dfa2b6176c 100644 (file)
@@ -9,8 +9,9 @@
 #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 @@ void python_init(char *argv0)
   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 @@ void python_init(char *argv0)
                                         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");
index 51a6f76ea60ee7c573b9d8526947e7fa9ffe4813..6c1551b5153dd0ef0990b7992859441895656c1a 100644 (file)
@@ -261,7 +261,7 @@ void Screen::calcArea()
 #endif // XINERAMA
 */
   
-  if (old_area != _area)
+  //if (old_area != _area)
     // XXX: re-maximize windows
 
   changeWorkArea();
This page took 0.049489 seconds and 4 git commands to generate.