window_configure(w, cev->x, cev->y,
cev->width, cev->height,
cev->border_width);
- if (window_is_mapped(w))
- sc->window_reconfigure(w);
+ if (window_is_mapped(w) &&
+ (width != cev->width ||
+ height != cev->height || bwidth != cev->border_width))
+ sc->window_resize(w);
}
above = screen_find_window(sc, cev->above_sibling);
screen_stacking_move_above(sc, w, above);
for (it = list_top(dpy->screens); it; it = it->next) {
d_screen_t *sc = it->data;
+ int id;
screen_setup_default_functions(sc);
/* these can be plugins.. */
- render_init(sc);
+ id = 1;
+ render_init(sc, id++);
}
}
--- /dev/null
+#include "plugin.h"
+#include "list.h"
+#include <stdlib.h>
+
+d_plugin_data_t*
+plugin_data_new(int id, void *data)
+{
+ d_plugin_data_t *pd = malloc(sizeof(d_plugin_data_t));
+ pd->id = id;
+ pd->data = data;
+ return pd;
+}
+
+void
+plugin_data_free(d_plugin_data_t *pd)
+{
+ if (pd) free(pd);
+}
+
+void
+plugin_data_add(d_list_t *list, int id, void *data)
+{
+ d_plugin_data_t *pd;
+ pd = plugin_data_new(id, data);
+ list_append(list, pd);
+}
+
+void*
+plugin_data_find(d_list_t *list, int id)
+{
+ d_list_it_t *it;
+ for (it = list_top(list); it; it = it->next) {
+ d_plugin_data_t *pd = it->data;
+ if (pd->id == id) return pd->data;
+ }
+ return NULL;
+}
+
+void
+plugin_data_remove(d_list_t *list, int id)
+{
+ d_list_it_t *it, *next;
+ for (it = list_top(list); it; it = next) {
+ d_plugin_data_t *pd = it->data;
+ next = it->next;
+ if (pd->id == id) list_delete_link(list, it);
+ }
+}
--- /dev/null
+#ifndef dc__plugin_h
+#define dc__plugin_h
+
+struct d_list;
+
+typedef struct d_plugin_data {
+ int id;
+ void *data;
+} d_plugin_data_t;
+
+d_plugin_data_t* plugin_data_new(int id, void *data);
+void plugin_data_free(d_plugin_data_t *pd);
+
+void plugin_data_add(struct d_list *list, int id, void *data);
+void plugin_data_remove(struct d_list *list, int it);
+void* plugin_data_find(struct d_list *list, int id);
+
+
+#endif
#include <stdlib.h>
#include <xcb/render.h>
-#define PLUGIN_NAME "render"
+static int plugin_id;
typedef struct {
void (*screen_paint)(d_screen_t *sc);
void (*window_show)(d_window_t *w);
void (*window_hide)(d_window_t *w);
- void (*window_reconfigure)(d_window_t *w);
+ void (*window_resize)(d_window_t *w);
xcb_render_query_pict_formats_reply_t *pict_formats;
xcb_render_picture_t overlay_picture;
static void render_screen_paint(d_screen_t *sc);
static void paint_root(d_screen_t *sc, data_t *d);
-static void paint_window(d_window_t *window);
+static void paint_window(d_window_t *window, data_t *d);
static void render_update_picture(d_window_t *w, data_t *d, window_data_t *wd,
gboolean children);
static void render_free_picture(d_window_t *w, window_data_t *wd);
static void render_window_show(d_window_t *window);
static void render_window_hide(d_window_t *window);
-static void render_window_reconfigure(d_window_t *window);
+static void render_window_resize(d_window_t *window);
void
-render_init(d_screen_t *sc)
+render_init(d_screen_t *sc, int id)
{
xcb_render_query_pict_formats_cookie_t ck;
xcb_render_pictformat_t format;
xcb_pixmap_t px;
+ plugin_id = id;
+
data_t *d = malloc(sizeof(data_t));
d->screen_paint = sc->screen_paint;
d->window_show = sc->window_show;
d->window_hide = sc->window_hide;
- d->window_reconfigure = sc->window_reconfigure;
- screen_add_plugin_data(sc, PLUGIN_NAME, d);
+ d->window_resize = sc->window_resize;
+ screen_add_plugin_data(sc, plugin_id, d);
sc->screen_paint = render_screen_paint;
sc->window_show = render_window_show;
sc->window_hide = render_window_hide;
- sc->window_reconfigure = render_window_reconfigure;
+ sc->window_resize = render_window_resize;
ck = xcb_render_query_pict_formats_unchecked(sc->dpy->conn);
d->pict_formats = xcb_render_query_pict_formats_reply(sc->dpy->conn, ck,
void
render_free(d_screen_t *sc)
{
- data_t *d = screen_find_plugin_data(sc, PLUGIN_NAME);
+ data_t *d = screen_find_plugin_data(sc, plugin_id);
free(d->pict_formats);
xcb_render_free_picture(sc->dpy->conn, d->solid_bg);
xcb_render_free_picture(sc->dpy->conn, d->overlay_picture);
data_t *d;
window_data_t *wd;
- d = screen_find_plugin_data(w->sc, PLUGIN_NAME);
+ d = screen_find_plugin_data(w->sc, plugin_id);
/* pass it on */
d->window_show(w);
- wd = window_find_plugin_data(w, PLUGIN_NAME);
+ wd = window_find_plugin_data(w, plugin_id);
if (wd)
render_window_free(w, wd);
wd = malloc(sizeof(window_data_t));
wd->picture = XCB_NONE;
wd->ck_picture.sequence = 0;
- window_add_plugin_data(w, PLUGIN_NAME, wd);
+ window_add_plugin_data(w, plugin_id, wd);
window_ref(w);
}
data_t *d;
window_data_t *wd;
- d = screen_find_plugin_data(w->sc, PLUGIN_NAME);
- wd = window_find_plugin_data(w, PLUGIN_NAME);
+ d = screen_find_plugin_data(w->sc, plugin_id);
+ wd = window_find_plugin_data(w, plugin_id);
if (wd) {
render_window_free(w, wd);
- window_remove_plugin_data(w, PLUGIN_NAME);
+ window_remove_plugin_data(w, plugin_id);
}
window_unref(w);
}
static void
-render_window_reconfigure(d_window_t *w)
+render_window_resize(d_window_t *w)
{
data_t *d;
window_data_t *wd;
- d = screen_find_plugin_data(w->sc, PLUGIN_NAME);
- wd = window_find_plugin_data(w, PLUGIN_NAME);
+ d = screen_find_plugin_data(w->sc, plugin_id);
+ wd = window_find_plugin_data(w, plugin_id);
render_free_picture(w, wd);
/* pass it on */
- d->window_reconfigure(w);
+ d->window_resize(w);
}
static void
render_screen_paint(d_screen_t *sc)
{
- data_t *d = screen_find_plugin_data(sc, PLUGIN_NAME);
+ data_t *d = screen_find_plugin_data(sc, plugin_id);
d_list_it_t *it;
//printf("-- painting --\n");
for (it = list_bottom(sc->stacking); it; it = it->prev) {
d_window_t *w = it->data;
if (!window_is_input_only(w) && window_is_mapped(w))
- paint_window(w);
+ paint_window(w, d);
}
#endif
}
static void
-paint_window(d_window_t *w)
+paint_window(d_window_t *w, data_t *d)
{
- data_t *d;
window_data_t *wd;
xcb_render_picture_t pict;
int x, y, width, height, bwidth;
- d = screen_find_plugin_data(w->sc, PLUGIN_NAME);
- wd = window_find_plugin_data(w, PLUGIN_NAME);
+ wd = window_find_plugin_data(w, plugin_id);
if (!wd->picture)
render_update_picture(w, d, wd, TRUE);
struct d_screen;
-void render_init(struct d_screen *sc);
+void render_init(struct d_screen *sc, int id);
void render_free(struct d_screen *sc);
#endif
#include "screen.h"
#include "display.h"
+#include "plugin.h"
#include "list.h"
#include "time.h"
#include "window.h"
sc->winhash = g_hash_table_new((GHashFunc)xcb_window_hash,
(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);
+ sc->plugin_data = list_new();
return sc;
}
if (sc && --sc->ref == 0) {
g_hash_table_unref(sc->winhash);
list_unref(sc->stacking);
- g_hash_table_unref(sc->plugin_data);
+ list_unref(sc->plugin_data);
free(sc);
}
}
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);
+ /* add time for the refresh rate (30 hz) */
+ time_add(&sc->next_repaint, 1000000/30);
sc->need_repaint = FALSE;
}
sc->window_show = window_show;
sc->window_hide = window_hide;
sc->window_become_zombie = window_become_zombie;
- sc->window_reconfigure = window_reconfigure;
+ sc->window_move = window_move;
+ sc->window_resize = window_resize;
}
void
-screen_add_plugin_data(d_screen_t *sc, const char *key, void *data)
+screen_add_plugin_data(d_screen_t *sc, int id, void *data)
{
- char *skey = g_strdup(key);
- g_hash_table_replace(sc->plugin_data, skey, data);
+ plugin_data_add(sc->plugin_data, id, data);
}
void*
-screen_find_plugin_data(d_screen_t *sc, const char *key)
+screen_find_plugin_data(d_screen_t *sc, int id)
{
- return g_hash_table_lookup(sc->plugin_data, key);
+ return plugin_data_find(sc->plugin_data, id);
}
void
-screen_remove_plugin_data(d_screen_t *sc, const char *key)
+screen_remove_plugin_data(d_screen_t *sc, int id)
{
- g_hash_table_remove(sc->plugin_data, key);
+ plugin_data_remove(sc->plugin_data, id);
}
void screen_refresh(d_screen_t *sc)
GHashTable *winhash;
struct d_list *stacking;
- GHashTable *plugin_data;
+ struct d_list *plugin_data;
void (*screen_paint)(struct d_screen *sc);
void (*window_show)(struct d_window *w);
void (*window_hide)(struct d_window *w);
void (*window_become_zombie)(struct d_window *w);
- void (*window_reconfigure)(struct d_window *w);
+ void (*window_move)(struct d_window *w);
+ void (*window_resize)(struct d_window *w);
} d_screen_t;
d_screen_t* screen_new(struct d_display *dpy, int num, xcb_screen_t *xcb);
void screen_setup_default_functions(d_screen_t *sc);
-void screen_add_plugin_data(d_screen_t *sc, const char *key, void *data);
-void* screen_find_plugin_data(d_screen_t *sc, const char *key);
-void screen_remove_plugin_data(d_screen_t *sc, const char *key);
+void screen_add_plugin_data(d_screen_t *sc, int id, void *data);
+void* screen_find_plugin_data(d_screen_t *sc, int id);
+void screen_remove_plugin_data(d_screen_t *sc, int id);
void screen_refresh(d_screen_t *sc);
#include "window.h"
#include "screen.h"
+#include "plugin.h"
+#include "list.h"
#include "display.h"
#include <stdlib.h>
#include <assert.h>
xcb_visualid_t visual;
xcb_pixmap_t pixmap;
+ double opacity;
+
gboolean zombie;
- GHashTable *plugin_data;
+ d_list_t *plugin_data;
xcb_damage_damage_t damage;
w->ck_get_pixmap.sequence = 0;
- w->plugin_data = g_hash_table_new_full((GHashFunc)g_str_hash,
- (GEqualFunc)g_str_equal,
- g_free, NULL);
+ w->plugin_data = list_new();
//printf("new window 0x%x\n", w->id);
w->pixmap = XCB_NONE;
}
- g_hash_table_unref(w->plugin_data);
+ list_unref(w->plugin_data);
free(w);
}
}
}
void
-window_reconfigure(d_window_t *w)
+window_move(d_window_t *w)
+{
+ (void)w;
+}
+
+void
+window_resize(d_window_t *w)
{
window_update_pixmap((d_window_priv_t*)w);
}
void
-window_add_plugin_data(d_window_t *pubw, const char *key, void *data)
+window_add_plugin_data(d_window_t *pubw, int id, void *data)
{
d_window_priv_t *w = (d_window_priv_t*)pubw;
- char *skey = g_strdup(key);
- g_hash_table_replace(w->plugin_data, skey, data);
+ plugin_data_add(w->plugin_data, id, data);
}
void*
-window_find_plugin_data(d_window_t *pubw, const char *key)
+window_find_plugin_data(d_window_t *pubw, int id)
{
d_window_priv_t *w = (d_window_priv_t*)pubw;
- return g_hash_table_lookup(w->plugin_data, key);
+ return plugin_data_find(w->plugin_data, id);
}
void
-window_remove_plugin_data(d_window_t *pubw, const char *key)
+window_remove_plugin_data(d_window_t *pubw, int id)
{
d_window_priv_t *w = (d_window_priv_t*)pubw;
- g_hash_table_remove(w->plugin_data, key);
+ plugin_data_remove(w->plugin_data, id);
}
void
void window_configure(d_window_t *w, int x, int y, int width, int height,
int border_width);
-void window_reconfigure(d_window_t *w);
+void window_move(d_window_t *w);
+void window_resize(d_window_t *w);
gboolean window_is_zombie(d_window_t *w);
gboolean window_is_input_only(d_window_t *w);
xcb_pixmap_t window_get_pixmap(d_window_t *w);
xcb_visualid_t window_get_visual(d_window_t *w);
-void window_add_plugin_data(d_window_t *w, const char *key, void *data);
-void* window_find_plugin_data(d_window_t *w, const char *key);
-void window_remove_plugin_data(d_window_t *w, const char *key);
+void window_add_plugin_data(d_window_t *w, int id, void *data);
+void* window_find_plugin_data(d_window_t *w, int id);
+void window_remove_plugin_data(d_window_t *w, int it);
void window_create_damage(d_window_t *w);
void window_destroy_damage(d_window_t *w);