+ Window root;
+ static Atom atom_current, atom_number, atom_names;
+ struct information *current_info = &info;
+ XWindowAttributes window_attributes;
+
+ root = RootWindow(current_display, current_info->x11.monitor.current);
+
+ /* Check if we initialise else retrieve changed property */
+ if (atom == 0) {
+ atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True);
+ atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True);
+ atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True);
+ get_x11_desktop_current(current_display, root, atom_current);
+ get_x11_desktop_number(current_display, root, atom_number);
+ get_x11_desktop_names(current_display, root, atom_names);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+
+ /* Set the PropertyChangeMask on the root window, if not set */
+ XGetWindowAttributes(display, root, &window_attributes);
+ if (!(window_attributes.your_event_mask & PropertyChangeMask)) {
+ XSetWindowAttributes attributes;
+ attributes.event_mask = window_attributes.your_event_mask | PropertyChangeMask;
+ XChangeWindowAttributes(display, root, CWEventMask, &attributes);
+ XGetWindowAttributes(display, root, &window_attributes);
+ }
+ } else {
+ if (atom == atom_current) {
+ get_x11_desktop_current(current_display, root, atom_current);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+ } else if (atom == atom_number) {
+ get_x11_desktop_number(current_display, root, atom_number);
+ } else if (atom == atom_names) {
+ get_x11_desktop_names(current_display, root, atom_names);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+ }
+ }
+}
+
+int update_x11info(void)
+{
+ struct information *current_info = &info;
+ if (x_initialised != YES)
+ return 0;
+ current_info->x11.monitor.number = XScreenCount(display);
+ current_info->x11.monitor.current = XDefaultScreen(display);
+ return 0;
+}
+
+#ifdef OWN_WINDOW
+/* reserve window manager space */
+void set_struts(int sidenum)
+{
+ Atom strut;
+ if ((strut = ATOM(_NET_WM_STRUT)) != None) {
+ /* reserve space at left, right, top, bottom */
+ signed long sizes[12] = {0};
+ int i;
+
+ /* define strut depth */
+ switch (sidenum) {
+ case 0:
+ /* left side */
+ sizes[0] = window.x + window.width;
+ break;
+ case 1:
+ /* right side */
+ sizes[1] = display_width - window.x;
+ break;
+ case 2:
+ /* top side */
+ sizes[2] = window.y + window.height;
+ break;
+ case 3:
+ /* bottom side */
+ sizes[3] = display_height - window.y;
+ break;
+ }
+
+ /* define partial strut length */
+ if (sidenum <= 1) {
+ sizes[4 + (sidenum*2)] = window.y;
+ sizes[5 + (sidenum*2)] = window.y + window.height;
+ } else if (sidenum <= 3) {
+ sizes[4 + (sidenum*2)] = window.x;
+ sizes[5 + (sidenum*2)] = window.x + window.width;
+ }
+
+ /* check constraints */
+ for (i = 0; i < 12; i++) {
+ if (sizes[i] < 0) {
+ sizes[i] = 0;
+ } else {
+ if (i <= 1 || i >= 8) {
+ if (sizes[i] > display_width) {
+ sizes[i] = display_width;
+ }
+ } else {
+ if (sizes[i] > display_height) {
+ sizes[i] = display_height;
+ }
+ }
+ }
+ }
+
+ XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *) &sizes, 4);
+
+ if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) {
+ XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *) &sizes, 12);
+ }
+ }
+}
+#endif /* OWN_WINDOW */
+
+#ifdef HAVE_XDBE
+void xdbe_swap_buffers(void)
+{
+ if (use_xdbe) {
+ //XWindowAttributes dest;//leaks
+ //XGetWindowAttributes(display, window.window, &dest);
+ //unsigned int src_height, src_width, src_depth = 0;
+ //XGetGeometry(display, window.back_buffer, NULL, NULL, NULL,src_width,src_height, NULL, src_depth);
+// fprintf(stderr, PACKAGE_NAME": copy from %d x %d x %d to %d x %d x %d\n",src_width, src_height, src_depth, dest.width, dest.height, dest.depth);
+ XCopyArea(display, window.drawable, window.window,
+ window.gc_back, 0, 0, window.width, window.height, 0, 0);
+ /* FIXME should fill w/ window background */
+ XSet
+/*
+ XFillRectangle(display, window.back_buffer, window.gc,
+ 0, 0, window.width, window.height);
+*/
+ }