setting up architecture for plugins. have a render-based drawer that doesn't do...
[dana/dcompmgr.git] / screen.c
index cbaf13a..55ee082 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -3,7 +3,6 @@
 #include "list.h"
 #include "time.h"
 #include "window.h"
-#include "render.h"
 #include "gettext.h"
 #include <string.h>
 #include <stdlib.h>
@@ -19,6 +18,7 @@
 static gboolean screen_init(d_screen_t *sc);
 static xcb_timestamp_t screen_timestamp(d_screen_t *sc);
 static void screen_add_existing_windows(d_screen_t *sc);
+static void screen_set_next_repaint(d_screen_t *sc);
 
 gboolean
 screen_register(struct d_display *dpy, int num, d_screen_t *sc)
@@ -87,7 +87,7 @@ static guint
 xcb_window_hash(xcb_window_t *w) { return *w; }
 
 static gboolean
-xcb_window_compare(xcb_window_t *w1, xcb_window_t *w2) { return *w1 == *w2; }
+xcb_window_equal(xcb_window_t *w1, xcb_window_t *w2) { return *w1 == *w2; }
 
 static gboolean
 screen_init(d_screen_t *sc)
@@ -133,14 +133,14 @@ screen_init(d_screen_t *sc)
     xcb_change_window_attributes(sc->dpy->conn, sc->super.root,
                                  XCB_CW_EVENT_MASK, &mask);
 
-    /* use the render backend */
-    sc->paint = render_paint_screen;
-
     gettimeofday(&sc->next_repaint, NULL);
 
     sc->winhash = g_hash_table_new((GHashFunc)xcb_window_hash,
-                                   (GCompareFunc)xcb_window_compare);
+                                   (GEqualFunc)xcb_window_equal);
     sc->stacking = list_new();
+    sc->plugin_data = g_hash_table_new_full((GHashFunc)g_str_hash,
+                                            (GEqualFunc)g_str_equal,
+                                            g_free, NULL);
 
     return TRUE;
 }
@@ -149,6 +149,7 @@ void screen_free(d_screen_t *sc)
 {
     g_hash_table_unref(sc->winhash);
     list_unref(sc->stacking);
+    g_hash_table_unref(sc->plugin_data);
 }
 
 void
@@ -190,7 +191,7 @@ screen_remove_window(d_screen_t *sc, struct d_window *w)
     printf("screen removed window 0x%x\n", w->id);
 
     g_hash_table_remove(sc->winhash, &w->id);
-    w->become_zombie(w);
+    sc->window_become_zombie(w);
     window_unref(w);
 }
 
@@ -249,10 +250,39 @@ screen_stacking_remove(d_screen_t *sc, struct d_window *w)
     list_remove(sc->stacking, w);
 }
 
-void
+static void
 screen_set_next_repaint(d_screen_t *sc)
 {
     gettimeofday(&sc->next_repaint, NULL);
     /* add time for the refresh rate (60 hz) */
     time_add(&sc->next_repaint, 1000000/60);
 }
+
+void
+screen_setup_default_functions(d_screen_t *sc)
+{
+    sc->screen_paint = screen_set_next_repaint;
+    sc->window_show = window_show;
+    sc->window_hide = window_hide;
+    sc->window_become_zombie = window_become_zombie;
+
+}
+
+void
+screen_add_plugin_data(d_screen_t *sc, const char *key, void *data)
+{
+    char *skey = g_strdup(key);
+    g_hash_table_insert(sc->plugin_data, skey, data);
+}
+
+void*
+screen_find_plugin_data(d_screen_t *sc, const char *key)
+{
+    return g_hash_table_lookup(sc->plugin_data, key);
+}
+
+void
+screen_remove_plugin_data(d_screen_t *sc, const char *key)
+{
+    g_hash_table_remove(sc->plugin_data, key);
+}