+#include "efence.h"
+
#include "screen.h"
#include "display.h"
#include "plugin.h"
#include <xcb/xfixes.h>
#define ROOT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \
- XCB_EVENT_MASK_STRUCTURE_NOTIFY)
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
+ XCB_EVENT_MASK_PROPERTY_CHANGE)
#define SELECTION_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
XCB_EVENT_MASK_PROPERTY_CHANGE)
screen_unref(d_screen_t *sc)
{
if (sc && --sc->ref == 0) {
+ d_list_it_t *it, *next;
+
+ /* clean up pending requests */
+ screen_get_root_pixmap(sc);
+
g_hash_table_unref(sc->winhash);
+ for (it = list_top(sc->stacking); it; it = next) {
+ next = it->next;
+ window_unref(it->data);
+ }
list_unref(sc->stacking);
list_unref(sc->plugin_data);
free(sc);
sck = xcb_get_selection_owner(sc->dpy->conn, arep->atom);
srep = xcb_get_selection_owner_reply(sc->dpy->conn, sck, NULL);
taken = srep->owner == w;
+ free(srep);
if (taken && screen_init(sc)) {
screen_add_existing_windows(sc);
ret = TRUE;
ret = FALSE;
}
}
+ g_free(arep);
xcb_ungrab_server(sc->dpy->conn);
xcb_flush(sc->dpy->conn);
xcb_change_window_attributes(sc->dpy->conn, sc->super.root,
XCB_CW_EVENT_MASK, &mask);
+ screen_update_root_pixmap(sc);
+
return TRUE;
}
+void
+screen_update_root_pixmap(d_screen_t *sc)
+{
+ if (sc->root_pixmap_waiting) {
+ xcb_get_property_reply_t *rep;
+ rep = xcb_get_property_reply(sc->dpy->conn, sc->root_pixmap_ck[0],
+ NULL);
+ if (rep) free(rep);
+ rep = xcb_get_property_reply(sc->dpy->conn, sc->root_pixmap_ck[1],
+ NULL);
+ if (rep) free(rep);
+ rep = xcb_get_property_reply(sc->dpy->conn, sc->root_pixmap_ck[2],
+ NULL);
+ if (rep) free(rep);
+ }
+ sc->root_pixmap_ck[0] =
+ xcb_get_property_unchecked(sc->dpy->conn, FALSE,
+ sc->super.root, sc->dpy->a.xrootpmap_id,
+ sc->dpy->a.pixmap, 0, 1);
+ sc->root_pixmap_ck[1] =
+ xcb_get_property_unchecked(sc->dpy->conn, FALSE,
+ sc->super.root, sc->dpy->a.esetroot_pmap_id,
+ sc->dpy->a.pixmap, 0, 1);
+ sc->root_pixmap_ck[2] =
+ xcb_get_property_unchecked(sc->dpy->conn, FALSE,
+ sc->super.root, sc->dpy->a.xsetroot_id,
+ sc->dpy->a.pixmap, 0, 1);
+ sc->root_pixmap_waiting = TRUE;
+}
+
d_window_t*
screen_add_window(d_screen_t *sc, xcb_window_t wid)
{
window_destroy_damage(w);
g_hash_table_remove(sc->winhash, &w->id);
- sc->window_become_zombie(w);
window_unref(w);
}
break;
}
}
- printf("created timestamp %lu\n", (unsigned long) time);
+ //printf("created timestamp %lu\n", (unsigned long) time);
return time;
}
list_move_before(sc->stacking, wit, ait);
}
+void screen_stacking_move_to_top(d_screen_t *sc, struct d_window *w)
+{
+ d_list_it_t *wit = list_find(sc->stacking, w);
+ d_list_it_t *ait = list_top(sc->stacking);
+ list_move_before(sc->stacking, wit, ait);
+}
+
+void screen_stacking_move_to_bottom(d_screen_t *sc, struct d_window *w)
+{
+ d_list_it_t *wit = list_find(sc->stacking, w);
+ list_move_before(sc->stacking, wit, NULL);
+}
+
static void
screen_set_next_repaint(d_screen_t *sc)
{
sc->window_show = window_show;
sc->window_hide = window_hide;
sc->window_become_zombie = window_become_zombie;
+ sc->window_zombie_dead = window_zombie_dead;
sc->window_move = window_move;
sc->window_resize = window_resize;
+ sc->window_reshape = window_reshape;
+ sc->window_opacity_change = window_opacity_change;
+ sc->screen_root_pixmap_change = screen_update_root_pixmap;
}
void
plugin_data_remove(sc->plugin_data, id);
}
-void screen_refresh(d_screen_t *sc)
+void
+screen_refresh(d_screen_t *sc)
{
sc->need_repaint = TRUE;
//printf("*** need repaint! ***\n");
}
+
+xcb_pixmap_t
+screen_get_root_pixmap(d_screen_t *sc)
+{
+ if (sc->root_pixmap_waiting) {
+ xcb_get_property_reply_t *rep;
+ int i;
+
+ sc->root_pixmap = XCB_NONE;
+ for (i = 2; i >= 0; --i) {
+ rep = xcb_get_property_reply(sc->dpy->conn, sc->root_pixmap_ck[i],
+ NULL);
+ if (rep) {
+ if (rep->type == sc->dpy->a.pixmap && rep->length >= 1) {
+ sc->root_pixmap =
+ ((xcb_pixmap_t*)xcb_get_property_value(rep))[0];
+ //printf("got root pixmap 0x%x\n", sc->root_pixmap);
+ }
+ free(rep);
+ }
+ }
+ }
+ return sc->root_pixmap;
+}