]> Dogcows Code - chaz/openbox/commitdiff
stop using python internally. add an event dispatcher
authorDana Jansens <danakj@orodu.net>
Mon, 17 Mar 2003 19:54:37 +0000 (19:54 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 17 Mar 2003 19:54:37 +0000 (19:54 +0000)
Makefile.am
configure.ac
openbox/Makefile.am
openbox/client.c
openbox/client.h
openbox/dispatch.c [new file with mode: 0644]
openbox/dispatch.h [new file with mode: 0644]
openbox/event.c
openbox/focus.c
openbox/openbox.c

index aff7de323e96b58cdaad7c6cce68ff880c93d802..be66ed9afeece30ac9b5a64178da1f260580b646 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = po data themes doc render kernel engines python
+SUBDIRS = po data themes doc render kernel engines plugins
 MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
 
 .PHONY: doc
index dc1404ca3686468a15f93515c0368df9cd3dbfcb..6754fcb4fce1afa87f6105785d72c2569ad567b4 100644 (file)
@@ -32,8 +32,6 @@ PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
 AC_SUBST(GMODULE_CFLAGS)
 AC_SUBST(GMODULE_LIBS)
        
-PYTHON_DEVEL
-
 AC_PROG_LN_S
 AC_PROG_LIBTOOL
 LIBTOOL="$LIBTOOL --silent"
@@ -63,7 +61,7 @@ AC_CONFIG_FILES([Makefile po/Makefile.in
                render/Makefile
                engines/Makefile
                engines/openbox/Makefile
-               python/Makefile
+               plugins/Makefile
                doc/Makefile
                doc/doxygen/Makefile
                data/Makefile
index 4cc5b4ce453cac8a5404184b2297d352d7748385..765cef215e68b7f2f61d40ba947f2d94d2bb141a 100644 (file)
@@ -1,31 +1,30 @@
 localedir=$(datadir)/locale
 themercdir=$(datadir)/openbox
-scriptdir=$(libdir)/openbox/python
 enginedir=$(libdir)/openbox/engines
+plugindir=$(libdir)/openbox/plugins
 
-CPPFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) $(GLIB_CFLAGS) $(GMODULE_CFLAGS) \
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) $(GMODULE_CFLAGS) \
 @CPPFLAGS@ \
 -DLOCALEDIR=\"$(localedir)\" \
 -DTHEMERCDIR=\"$(themercdir)\" \
--DSCRIPTDIR=\"$(scriptdir)\" \
+-DPLUGINDIR=\"$(plugindir)\" \
 -DENGINEDIR=\"$(enginedir)\" \
 -DDEFAULT_ENGINE=\"openbox\" \
 -DG_LOG_DOMAIN=\"Openbox\"
 
-LIBS=$(XFT_LIBS) $(PYTHON_LIBS) $(GLIB_LIBS) $(GMODULE_LIBS) @LIBS@
+LIBS=$(XFT_LIBS) $(GLIB_LIBS) $(GMODULE_LIBS) @LIBS@
 
 bin_PROGRAMS= ob3
 
 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 configwrap.c
+       screen.c stacking.c xerror.c themerc.c timer.c dispatch.c \
+       engine.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 configwrap.h
+       openbox.h prop.h screen.h stacking.h xerror.h themerc.h dispatch.h \
+       timer.h engine.h
 
 MAINTAINERCLEANFILES= Makefile.in
 
index fdc171fb87a80cfa6d373ec36e4839c149371722..fcc7fd6ae2a2e6820ede0bf1df35409ceb5ff3ed 100644 (file)
@@ -7,11 +7,8 @@
 #include "event.h"
 #include "focus.h"
 #include "stacking.h"
-#include "pointer.h"
-#include "hooks.h"
-#include "openboxwrap.h"
-#include "clientwrap.h"
 
+#include <glib.h>
 #include <X11/Xutil.h>
 
 /*! The event mask to grab on client windows */
@@ -122,7 +119,6 @@ void client_manage(Window window)
     XWindowAttributes attrib;
     XSetWindowAttributes attrib_set;
 /*    XWMHints *wmhint; */
-    PyObject *cw;
      
     XGrabServer(ob_display);
     XSync(ob_display, FALSE);
@@ -198,17 +194,12 @@ void client_manage(Window window)
 
     screen_update_struts();
 
-    /* add to the python list */
-    cw = clientwrap_new(client);
-    PyList_Append(openboxwrap_obj->client_list, cw);
-    Py_DECREF(cw);
-
-    HOOKFIRECLIENT(managed, client);
+    /*HOOKFIRECLIENT(managed, client);XXX*/
 
     client_showhide(client);
 
     /* grab all mouse bindings */
-    pointer_grab_all(client, TRUE);
+    /*pointer_grab_all(client, TRUE);XXX*/
 
     /* update the list hints */
     client_set_list();
@@ -224,13 +215,12 @@ void client_unmanage_all()
 
 void client_unmanage(Client *client)
 {
-    int j, seq;
-    PyObject *cw;
+    int j;
     GSList *it;
 
     g_message("Unmanaging window: %lx", client->window);
 
-    HOOKFIRECLIENT(closed, client);
+    /*HOOKFIRECLIENT(closed, client);XXX*/
 
     /* remove the window from our save set */
     XChangeSaveSet(ob_display, client->window, SetModeDelete);
@@ -239,7 +229,7 @@ void client_unmanage(Client *client)
     XSelectInput(ob_display, client->window, NoEventMask);
 
     /* ungrab any mouse bindings */
-    pointer_grab_all(client, FALSE);
+    /*pointer_grab_all(client, FALSE);XXX*/
      
     engine_frame_hide(client->frame);
 
@@ -257,19 +247,6 @@ void client_unmanage(Client *client)
        influence */
     screen_update_struts();
 
-    /* remove from the python list */
-    cw = clientwrap_new(client);
-    seq = PySequence_Index(openboxwrap_obj->client_list, cw);
-    if (seq == -1)
-       PyErr_Clear();
-    else
-       PySequence_DelItem(openboxwrap_obj->client_list, seq);
-    Py_DECREF(cw);
-
-    /* notify the wrapper that its useless now */
-    if (client->wrap != NULL)
-       client->wrap->client = NULL;
-
     /* tell our parent that we're gone */
     if (client->transient_for != NULL)
        client->transient_for->transients =
@@ -402,7 +379,6 @@ static void client_get_all(Client *self)
     self->disabled_decorations = 0;
     self->group = None;
     self->nicons = 0;
-    self->wrap = NULL;
 
     client_get_area(self);
     client_get_desktop(self);
@@ -947,7 +923,7 @@ void client_update_wmhints(Client *self)
        /* fire the urgent callback if we're mapped, otherwise, wait until
           after we're mapped */
        if (self->frame)
-           HOOKFIRECLIENT(urgent, self);
+           /*HOOKFIRECLIENT(urgent, self)XXX*/;
     }
 }
 
@@ -1242,7 +1218,7 @@ static void client_showhide(Client *self)
     else
         engine_frame_hide(self->frame);
 
-    HOOKFIRECLIENT(visible, self);
+    /*HOOKFIRECLIENT(visible, self);XXX*/
 }
 
 gboolean client_normal(Client *self) {
@@ -1267,7 +1243,7 @@ static void client_apply_startup_state(Client *self)
        client_shade(self, TRUE);
     }
     if (self->urgent)
-       HOOKFIRECLIENT(urgent, self);
+       /*HOOKFIRECLIENT(urgent, self)XXX*/;
   
     if (self->max_vert && self->max_horz) {
        self->max_vert = self->max_horz = FALSE;
index b41f0644d01bd0acae0ceb49bff5ac246e8989e7..442e7107b84431fb67ac9f9552542371ef27e0d7 100644 (file)
@@ -6,7 +6,6 @@
 #include <glib.h>
 #include <X11/Xlib.h>
 
-struct ClientWrap;
 struct Frame;
 
 
@@ -279,9 +278,6 @@ typedef struct Client {
     Pixmap pixmap_icon;
     /*! The mask for the pixmap_icon, or None if its not masked */
     Pixmap pixmap_icon_mask;
-
-    /* The instance of the wrapper class if one exists */
-    struct ClientWrap *wrap;
 } Client;
 
 extern GSList *client_list;
diff --git a/openbox/dispatch.c b/openbox/dispatch.c
new file mode 100644 (file)
index 0000000..c710dec
--- /dev/null
@@ -0,0 +1,151 @@
+#include "dispatch.h"
+
+#include <glib.h>
+
+static GSList **funcs;
+
+void dispatch_startup()
+{
+    guint i;
+    EventType j;
+
+    i = 0;
+    j = EVENT_RANGE;
+    while (j > 1) {
+        j >>= 1;
+        ++i;
+    }
+    funcs = g_new(GSList*, i);
+
+    for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1)
+        funcs[i] = NULL;
+}
+
+void dispatch_shutdown()
+{
+    guint i;
+    EventType j;
+
+    for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1)
+        g_slist_free(funcs[i]);
+
+    g_free(funcs);
+}
+
+void dispatch_register(EventHandler h, EventMask mask)
+{
+    guint i;
+    EventType j;
+
+    while (mask) {
+        for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1)
+            if (mask & j) {
+                funcs[i] = g_slist_append(funcs[i], h);
+                mask ^= j; /* remove from the mask */
+            }
+        g_assert(j >= EVENT_RANGE); /* an invalid event is in the mask */
+    }
+}
+
+void dispatch_x(XEvent *xe)
+{
+    EventType e;
+    guint i;
+    GSList *it;
+    ObEvent obe;
+
+    switch (xe->type) {
+    case EnterNotify:
+        e = Event_X_EnterNotify;
+        break;
+    case LeaveNotify:
+        e = Event_X_LeaveNotify;
+        break;
+    case KeyPress:
+        e = Event_X_KeyPress;
+        break;
+    case KeyRelease:
+        e = Event_X_KeyRelease;
+        break;
+    case ButtonPress:
+        e = Event_X_ButtonPress;
+        break;
+    case ButtonRelease:
+        e = Event_X_ButtonRelease;
+        break;
+    case MotionNotify:
+        e = Event_X_MotionNotify;
+        break;
+    default:
+        return;
+    }
+
+    obe.type = e;
+    obe.data.x = xe;
+
+    i = 0;
+    while (e > 1) {
+        e >>= 1;
+        ++i;
+    }
+
+    for (it = funcs[i]; it != NULL; it = it->next)
+        ((EventHandler)it->data)(&obe);
+}
+
+void dispatch_client(EventType e, Client *c)
+{
+    guint i;
+    GSList *it;
+    ObEvent obe;
+
+    obe.type = e;
+    obe.data.client = c;
+
+    i = 0;
+    while (e > 1) {
+        e >>= 1;
+        ++i;
+    }
+
+    for (it = funcs[i]; it != NULL; it = it->next)
+        ((EventHandler)it->data)(&obe);
+}
+
+void dispatch_ob(EventType e)
+{
+    guint i;
+    GSList *it;
+    ObEvent obe;
+
+    obe.type = e;
+
+    i = 0;
+    while (e > 1) {
+        e >>= 1;
+        ++i;
+    }
+
+    for (it = funcs[i]; it != NULL; it = it->next)
+        ((EventHandler)it->data)(&obe);
+}
+
+void dispatch_signal(int signal)
+{
+    guint i;
+    EventType e = Event_Signal;
+    GSList *it;
+    ObEvent obe;
+
+    obe.type = e;
+    obe.data.signal = signal;
+
+    i = 0;
+    while (e > 1) {
+        e >>= 1;
+        ++i;
+    }
+
+    for (it = funcs[i]; it != NULL; it = it->next)
+        ((EventHandler)it->data)(&obe);
+}
diff --git a/openbox/dispatch.h b/openbox/dispatch.h
new file mode 100644 (file)
index 0000000..c8371b9
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __dispatch_h
+#define __dispatch_h
+
+#include "client.h"
+#include <X11/Xlib.h>
+
+void dispatch_startup();
+void dispatch_shutdown();
+
+typedef enum {
+    Event_X_EnterNotify   = 1 << 0,
+    Event_X_LeaveNotify   = 1 << 1,
+    Event_X_KeyPress      = 1 << 2,
+    Event_X_KeyRelease    = 1 << 3,
+    Event_X_ButtonPress   = 1 << 4,
+    Event_X_ButtonRelease = 1 << 5,
+    Event_X_MotionNotify  = 1 << 6,
+
+    Event_Client_New      = 1 << 7, /* new window, before mapping */
+    Event_Client_Mapped   = 1 << 8, /* new window, after mapping */
+    Event_Client_Destroy  = 1 << 9, /* unmanaged */
+    Event_Client_Focus    = 1 << 10,
+    Event_Client_Unfocus  = 1 << 11,
+
+    Event_Ob_Desktop      = 1 << 12, /* changed desktops */
+    Event_Ob_NumDesktops  = 1 << 13, /* changed the number of desktops */
+    Event_Ob_ShowDesktop  = 1 << 14, /* entered/left show-the-desktop mode */
+    Event_Ob_Startup      = 1 << 15, /* startup complete */
+    Event_Ob_Shutdown     = 1 << 16, /* shutdown about to start */
+
+    Event_Signal          = 1 << 17,
+
+    EVENT_RANGE           = 1 << 18
+} EventType;
+
+typedef union {
+    XEvent *x; /* for Event_X_* event types */
+    Client *client; /* for Event_Client_* event types */
+    int signal;
+} EventData;
+
+typedef struct {
+    EventType type;
+    EventData data;
+} ObEvent;
+
+typedef void (*EventHandler)(const ObEvent *e);
+
+typedef unsigned int EventMask;
+
+void dispatch_register(EventHandler h, EventMask mask);
+
+void dispatch_x(XEvent *e);
+void dispatch_client(EventType e, Client *c);
+void dispatch_ob(EventType e);
+void dispatch_signal(int signal);
+
+#endif
index 0cf9cf1475fd52c49770595aa543b6528706177c..341db70641ec27dcdf0e04fb4bb2e5a1a6ec1e3b 100644 (file)
@@ -7,9 +7,6 @@
 #include "engine.h"
 #include "focus.h"
 #include "stacking.h"
-#include "keyboard.h"
-#include "pointer.h"
-#include "hooks.h"
 #include "extensions.h"
 #include "timer.h"
 #include "engine.h"
@@ -286,37 +283,37 @@ void event_process(XEvent *e)
     switch(e->type) {
     case EnterNotify:
         if (client != NULL) engine_mouse_enter(client->frame, window);
-       HOOKFIRECLIENT(pointerenter, client);
+       /*HOOKFIRECLIENT(pointerenter, client);XXX*/
        break;
     case LeaveNotify:
         if (client != NULL) engine_mouse_leave(client->frame, window);
-       HOOKFIRECLIENT(pointerleave, client);
+       /*HOOKFIRECLIENT(pointerleave, client);XXX*/
        break;
     case ButtonPress:
         if (client != NULL) 
             engine_mouse_press(client->frame, window,
                                e->xbutton.x, e->xbutton.y);
-       pointer_event(e, client);
+       /*pointer_event(e, client);XXX*/
         break;
     case ButtonRelease:
         if (client != NULL)
             engine_mouse_release(client->frame, window,
                                  e->xbutton.x, e->xbutton.y);
-       pointer_event(e, client);
+       /*pointer_event(e, client);XXX*/
         break;
     case MotionNotify:
-       pointer_event(e, client);
+       /*pointer_event(e, client);XXX*/
        break;
     case KeyPress:     
     case KeyRelease:
-       keyboard_event(&e->xkey);
+       /*keyboard_event(&e->xkey);XXX*/
        break;
     default:
        /* XKB events */
        if (e->type == extensions_xkb_event_basep) {
            switch (((XkbAnyEvent*)&e)->xkb_type) {
            case XkbBellNotify:
-               HOOKFIRECLIENT(bell, client);
+               /*HOOKFIRECLIENT(bell, client);XXX*/
                break;
            }
        }
@@ -494,7 +491,7 @@ static void event_handle_client(Client *client, XEvent *e)
        /* we shouldn't be able to get this unless we're iconic */
        g_assert(client->iconic);
 
-       HOOKFIRECLIENT(requestactivate, client);
+       /*HOOKFIRECLIENT(requestactivate, client);XXX*/
        break;
     case ClientMessage:
        /* validate cuz we query stuff off the client here */
@@ -554,7 +551,7 @@ static void event_handle_client(Client *client, XEvent *e)
                /* if its not visible for other reasons, then don't mess
                   with it */
                return;
-           HOOKFIRECLIENT(requestactivate, client);
+           /*HOOKFIRECLIENT(requestactivate, client);XXX*/
        }
        break;
     case PropertyNotify:
index 3c7b635baaa23b0712bce29cd7b9c445fbd4b5fa..4ef4b90ca2bd47af18f8b259b5efd53fe7d853ba 100644 (file)
@@ -2,7 +2,6 @@
 #include "client.h"
 #include "screen.h"
 #include "prop.h"
-#include "hooks.h"
 
 #include <X11/Xlib.h>
 
@@ -53,5 +52,5 @@ void focus_set_client(Client *client)
     active = client ? client->window : None;
     PROP_SET32(ob_root, net_active_window, window, active);
 
-    HOOKFIRECLIENT(focused, client);
+    /*HOOKFIRECLIENT(focused, client);XXX*/
 }
index c77f6df1151ee16b099f57d7d9df7cbe201e5b51..c0ffa4203fa9a707e0f6dc410a356a045e415c63 100644 (file)
@@ -1,20 +1,14 @@
 #include "openbox.h"
 #include "event.h"
 #include "client.h"
+#include "dispatch.h"
 #include "xerror.h"
 #include "prop.h"
 #include "screen.h"
 #include "focus.h"
 #include "extensions.h"
 #include "gettext.h"
-#include "keyboard.h"
-#include "pointer.h"
 #include "engine.h"
-#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"
@@ -130,27 +124,17 @@ int main(int argc, char **argv)
      
     if (screen_annex()) { /* it will be ours! */
        timer_startup();
+        dispatch_startup();
        render_startup();
        font_startup();
        themerc_startup();
        engine_startup(themerc_engine);
-       python_startup();
-        configwrap_startup();
-       openboxwrap_startup();
-       clientwrap_startup();
-       hooks_startup();
        event_startup();
        screen_startup();
        focus_startup();
        client_startup();
-       keyboard_startup();
-       pointer_startup();
          
-       /* load the user's settings */
-       if (!python_import("rc"))
-           g_warning("ERROR LOADING RC FILE");
-
-       HOOKFIRE(startup, "()");
+       /*HOOKFIRE(startup, "()");XXX*/
 
        /* get all the existing windows */
        client_manage_all();
@@ -163,21 +147,15 @@ int main(int argc, char **argv)
 
        client_unmanage_all();
 
-       HOOKFIRE(shutdown, "()");
+       /*HOOKFIRE(shutdown, "()");XXX*/
 
-       pointer_shutdown();
-       keyboard_shutdown();
        client_shutdown();
        screen_shutdown();
        event_shutdown();
-       hooks_shutdown();
-       clientwrap_shutdown();
-       openboxwrap_shutdown();
-        configwrap_shutdown();
-       python_shutdown();
        engine_shutdown();
        themerc_shutdown();
        render_shutdown();
+        dispatch_shutdown();
        timer_shutdown();
     }
          
This page took 0.041086 seconds and 4 git commands to generate.